某网站包含两个表,Customers
表和 Orders
表。编写一个 SQL 查询,找出所有从不订购任何东西的客户。
使用 left join ...on 左连接,Orders表数据为空时 显示值为 null. 然后where 条件查找为null的值。
select C.Name as Customers from Customers C left join Orders O on O.CustomerId = C.Id where O.Id is null;
某网站包含两个表,Customers
表和 Orders
表。编写一个 SQL 查询,找出所有从不订购任何东西的客户。
使用 left join ...on 左连接,Orders表数据为空时 显示值为 null. 然后where 条件查找为null的值。
select C.Name as Customers from Customers C left join Orders O on O.CustomerId = C.Id where O.Id is null;