Fork me on GitHub

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
posted @ 2023-11-02 15:58  HelloLLLLL  阅读(144)  评论(0编辑  收藏  举报