Cartesian Joins 笛卡兒聯接
SELECT *
FROM 表格A ,表格B
將表格所有可能聯接,全都資料聯接。
如果要限制,可以在WHERE加條件。
例:
SELECT *
FROM user AS u, occupation AS o
結果:
例:
SELECT *
FROM user AS u, occupation AS o
WHERE u.id = o.user_id
結果:
具有相同效果的JOIN語句是 CROSS JOIN
此JOIN不需要ON的條件限制,與table1,table2 效果相同
例︰
SELECT *
FROM user AS u CROSS JOIN occupation AS o
SELECT *
FROM user AS u CROSS JOIN occupation AS o
WHERE u.id = o.user_id
其它文章
沒有留言:
張貼留言