MySQL - is it legal to do 'SELECT table1.*,table2.column FROM table1,table2'
?
views:
103answers:
2
+7
A:
It is legal, but it will give you a Cartesian product of the two tables. Are you sure that you want a Cartesian Product?
Most times, you would use a JOIN as in:
Select Table1.*, Table2,ColumnName
From Table1
INNER JOIN Table2
ON Table1.PKColumn = Table2.FKColumn
Raj More
2009-11-28 23:41:33
For those of you running for the dictionary *(which I did, even tho I knew what he was talking about xD)*, here a Cartesian Product means; all possible combinations of rows from both tables. Two tables with 5 rows each, joined in this manner, will result in a 25 row result set. Not ideal in most cases.
Atli
2009-11-29 00:31:51
A:
While this theta syntax is legal, it's just too easy to miss a join condition without the parser warning you.
fenway
2009-11-29 14:53:33