SELECT sh__shop.id AS shop_id, sh__shop.name。
sh__shop_invoice.*
FROM sh__shop
LEFT JOIN sh__shop_invoice ON sh__shop_invoice.shop_id= sh__shop.id
WHERE sh__shop_invoice.month_commission LIKE "2021-08-01"
但我看不出如何得到反面的資訊。所有的商店在特定日期沒有發票。我不能做到NOT LIKE "2021-08-01"。
uj5u.com熱心網友回復:
你可以通過使用not exists來實作。
SELECT sh__shop.id AS shop_id, sh__shop.name
FROM sh__shop
WHERE[/span
NOT EXISTS (SELECT * FROM sh__shop_invoice i
WHERE i.shop_id = sh__shop.id
and i.month_commission LIKE "2021-08-01")。)
uj5u.com熱心網友回復:
你可以嘗試使用左鍵連接,但是對于nkt匹配行
SELECT distnct sh__shop.id AS shop_id
FROM sh__shop
LEFT JOIN sh__shop_invoice ON sh__shop_invoice.shop_id = sh__shop.id
AND sh__shop_invoice.month_commission LIKE "2021-08-01"
WHERE sh__shop_invoice.shop_id is null
(在你的查詢中,你以錯誤的方式使用了左鍵連接,因為在where子句中添加了左鍵連接的列,這作為一個內部連接作業)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/320148.html
標籤:
