tags:

views:

103

answers:

2

MySQL - is it legal to do 'SELECT table1.*,table2.column FROM table1,table2'?

+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
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
A: 

While this theta syntax is legal, it's just too easy to miss a join condition without the parser warning you.

fenway