简体   繁体   中英

SQL - Difference between using "CROSS JOIN" and ","

is there any difference between writing select * from R,S and select * from R CROSS JOIN S ?

Actually, there is. The issue is semantically how the rest of the query is parsed. So (according to the rules of standard SQL), I don't think the following works:

from a, b join
     c
     on a.x = c.x

The , stops the a from being recognized in the result of the from clause.

However, this does work:

from a cross join b join
     c
     on a.x = c.x

Note: The first version might work in some databases.

Also, I strongly recommend that you never use commas in the FROM clause. This is not about rules. It is about writing clear code and being explicit about how your query is going to combine data from multiple tables.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM