mysql,左連接 ,查詢右表爲null的寫法,刪除,帶join條件的寫法

select * from sale_guest sg left join sale_bill sb
on sg.bill_id=sb.id where sg.gmt_create>'2023-10-20' and sb.bill_no is NULL

select * from sale_emp se left join sale_bill sb
on se.bill_id=sb.id where se.gmt_create>'2023-10-20' and sb.bill_no is NULL

select * from sale_item si left join sale_bill sb
on si.bill_id=sb.id where si.gmt_create>'2023-10-20' and sb.bill_no is NULL

delete si  from sale_item si left join sale_bill sb
on si.bill_id=sb.id where si.gmt_create>'2023-10-20' and sb.bill_no is NULL

delete se from sale_emp se left join sale_bill sb
on se.bill_id=sb.id where se.gmt_create>'2023-10-20' and sb.bill_no is NULL

delete sg from sale_guest sg left join sale_bill sb
on sg.bill_id=sb.id where sg.gmt_create>'2023-10-20' and sb.bill_no is NULL
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章