In SQL, what's the difference between JOIN and CROSS JOIN?

后端 未结 3 394
伪装坚强ぢ
伪装坚强ぢ 2021-02-06 05:36

What\'s the difference between:

select t1.a1, t1.a2, t1.a3 from t1 cross join t2 where t1.a3 = t2.a1

and:

select t1.a1, t1.a2,          


        
3条回答
  •  时光取名叫无心
    2021-02-06 06:00

    MySQL doesn't offer a distinction between JOIN and CROSS JOIN. They are the same.

    In both your examples the clause

    WHERE t1.a3 = t2.a1 
    

    converts any sort of join into an inner join. The standard way of expressing this query is

    SELECT t1.a1, t1.a2, t1.a3 
      FROM t1 
      JOIN t2 ON t1.a3 = t2.a1
    

提交回复
热议问题