SELECT a.*,b.custom_name FROM zqwl_receipt a , zqwl_custom b LEFT JOIN b WHERE a.id= b.id
学习是最好的投资!
left join的用法一般是先查詢主表再join其他表的,例如
left join
select a.*, b.custom_name from zqwl_receipt a left join zqwl_custom b on a.id = b.id
如果你希望a、b兩個表結合查詢的結果再做關聯查找的話,或許可以用子查詢的方式
select * from ( select a.*, b.custom_name from zqwl_receipt a, zqwl_custom b where a.id = b.id ) t left join zqwl_custom t2 on t2.id = t.id
但是如果寫出這樣的語句來,最好要要思考a, b兩個表的設計問題,或者這完全就是沒有必要的
從 xxx LEFT JOIN xxx 選擇 zqwl_receipt.*,zqwl_custom.custom_name
從a左加入b on a.id=b.id
你的FROM 去哪裡了
沒有 from 表沒有 on 來篩選這兩個表的關係。
SELECT zqwl_receipt.*,zqwl_custom.custom_name from zqwl_receipt LEFT JOIN zqwl_custom on zqwl_custom.欄位= zqwl_receiptwl_custom on zqwl_custom.欄位= zqwl_receiptwl_custom
基本語法錯誤
left join
的用法一般是先查詢主表再join其他表的,例如如果你希望a、b兩個表結合查詢的結果再做關聯查找的話,或許可以用子查詢的方式
但是如果寫出這樣的語句來,最好要要思考a, b兩個表的設計問題,
或者這完全就是沒有必要的
從 xxx LEFT JOIN xxx 選擇 zqwl_receipt.*,zqwl_custom.custom_name
從a左加入b on a.id=b.id
你的FROM 去哪裡了
沒有 from 表
沒有 on 來篩選這兩個表的關係。
SELECT zqwl_receipt.*,zqwl_custom.custom_name from zqwl_receipt LEFT JOIN zqwl_custom on zqwl_custom.欄位= zqwl_receiptwl_custom on zqwl_custom.欄位= zqwl_receiptwl_custom
on zqwl_custom.字段= zqwl_receipt.wl_custom 🎜on zqwl_custom.欄位= zqwl_receipt.T.基本語法錯誤