inner join和cross join的使用

inner join和cross join的使用和逗号是一样的效果,其中的区别就是,inner join产生的是交叉连接,而cross join是产生内连接而已。

例:

select countryname,statename from country,state 等价于select countryname,statename from country cross join state;

select countryname,statename from country,state where state.cid = country.id 等价于 elect countryname,statename from country inner join state where state.cid = country.id;

 

而且,这两个关键字和逗号都可以尽可能多的连接很多的表:

select * from country cross join state cross join city;

你可能感兴趣的:(mysql,连接)