| Author |
Topic |
|
nathans
Aged Yak Warrior
938 Posts |
Posted - 2005-01-04 : 14:31:47
|
| Guys,Im just doing some JOIN exercises. Can we assume that a CROSS JOIN is the same as INNER JOIN ON 1 = 1 in all cases?Thanks! |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2005-01-04 : 15:29:30
|
| The INNER JOIN ON 1 = 1 will evaluate True for every combination of rows in the two tables. This is the same as a CROSS JOIN. The real question becomes, "Why would you want to do this?"HTH=================================================================Where it is a duty to worship the sun, it is pretty sure to be a crime to examine the laws of heat. -John Morley, statesman and writer (1838-1923) |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2005-01-04 : 15:34:32
|
| Ummm....Dr.?Brett8-) |
 |
|
|
nathans
Aged Yak Warrior
938 Posts |
Posted - 2005-01-04 : 15:36:47
|
| I was just trying to understand how the CROSS JOIN functions in comparison to the INNER. I would never use the 1 = 1 syntax.Thanks HTH |
 |
|
|
rockmoose
SQL Natt Alfen
3279 Posts |
Posted - 2005-01-04 : 15:52:19
|
| Yes, both will produce the "Cartesian product" of the tables involved.Can also be accomplished withselect * from table1,table2(which is also a reason not to use that syntax, since you can get "unexpectly large" results)rockmoose |
 |
|
|
nathans
Aged Yak Warrior
938 Posts |
Posted - 2005-01-04 : 15:58:37
|
| Thanks.> Ummmm....Dr.?Brett? |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
nathans
Aged Yak Warrior
938 Posts |
Posted - 2005-01-04 : 16:13:38
|
| Thanks all! Ill be sure to read up.- Nathan |
 |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2005-01-04 : 16:42:05
|
| Nathans,Remember that the join condition is just an expression that gets evaluated for every combination of rows in the two tables. If it evaluates to true then that combination of rows gets included as part of the join. It's easy to get distracted from this fact since most joins we do are usually some variation of t1.MyKey = t2.YourKey and are almost always based on data within the tables.Your join predicate of "1 = 1", though academic in nature, is a good example that the join could be anything. This might not seem like a big deal now but it will come in handy when you start working with non-equijoins.HTH=================================================================Where it is a duty to worship the sun, it is pretty sure to be a crime to examine the laws of heat. -John Morley, statesman and writer (1838-1923) |
 |
|
|
Arnold Fribble
Yak-finder General
1961 Posts |
Posted - 2005-01-05 : 07:02:43
|
| T1 FULL OUTER JOIN T2 ON 1 = 0 is fun, though potentially confusing. |
 |
|
|
|