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 |
|
smile
Starting Member
22 Posts |
Posted - 2009-03-15 : 17:26:36
|
| Hello again!Here's my question: let's say I have two tables - t1 and t2, and the query "select count(*) from t1 " returns 9, and "select count(*) from t2" returns 8. The why the query "select count(*) from t1,t2" returns 72? I see that the two results are multiplied but I don't get why...? So it does something like Cartesian product? |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2009-03-15 : 18:02:07
|
| yesselect count(*) from t1,t2creates a cross join between t1 and t2 which is the same as a cartesian product___________________________________________________________________________Causing trouble since 1980Blog: http://weblogs.sqlteam.com/mladenpSpeed up SSMS development: www.ssmstoolspack.com <- version 1.5 out! |
 |
|
|
smile
Starting Member
22 Posts |
Posted - 2009-03-15 : 18:14:07
|
| Ok, thanks! |
 |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-03-16 : 00:11:47
|
| If you want the count as t1 by joining t2The query seems like Select count(a.*) from t1 a,t2 b where a.id=b.idRegardsSenthil.CWilling to update... |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-16 : 11:34:16
|
| staring from sql 2005, you should busing new join syntax instead of below syntax as this wont be supported in future version of sql. |
 |
|
|
|
|
|