Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
kshitizgp
Starting Member
31 Posts |
Posted - 2011-12-15 : 03:34:52
|
There are three broad divisions of subquery:Single-row subqueriesMultiple-row subqueriesCorrelated subqueriescan u guyz explain with simple examples plsssssssssss ..... thnx alot for ur this forum :) |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-15 : 03:40:18
|
| the names itself are self explanatorysingle row subquery returns a single row of data to query of which its a part.multiple row subqueries as name implies returns a resultset and in most cases will end in a cross join (cartesian product) with rest of query part unless you specify relation on basis of on conditioncorrelated subquery involves relating the subquery with main query part using column or columns which will be passed into subquery and will do checking inside------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2011-12-15 : 03:43:53
|
| Single row subqueriesSelect * from table_name where id=(Select id from table_name where primary_key_column = 1)Multiple-row subqueriesSelect * from table_name where column_name in (select column_name from table_name)Correlated subqueriesSeelct t1.col1,t2.col1 from t1 inner join(Select col1,col2,col3 from table )t2 on t1.col1=t2.col1 Senthil Kumar C------------------------------------------------------MCITP - Database Administration SQL SERVER 2008MCTS - Database Development SQL SERVER 2008 |
 |
|
|
|
|
|