开发者

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

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. 开发者_开发知识库 Closed 10 years ago.

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


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜