SELECT customer.cust_name
FROM customer INNER JOIN sales_detail ON customer.cust_id = sales_detail.cust_id
WHERE customer.cust_id Not In (SELECT cust_id FROM sales_detail);
ACCESS想查找一下customer里cust_id有但sales_detail表里cust_id无的数据,SQL写完运行无结果
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
关注- not in
SELECT customer.cust_name FROM customer WHERE customer.cust_id Not In (SELECT cust_id FROM sales_detail); - not exists
SELECT customer.cust_name FROM customer WHERE Not exists (SELECT 1 FROM sales_detail where customer.cust_id=sales_detail.cust_id); - left join
SELECT distinct customer.cust_name FROM customer left JOIN sales_detail ON customer.cust_id = sales_detail.cust_id WHERE sales_detail.cust_id is null
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报- not in