Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL query to find all customers who never order anything.

Table: Customers.

+----+-------+
| Id | Name  |
+----+-------+
| 1  | Joe   |
| 2  | Henry |
| 3  | Sam   |
| 4  | Max   |
+----+-------+

Table: Orders.

+----+------------+
| Id | CustomerId |
+----+------------+
| 1  | 3          |
| 2  | 1          |
+----+------------+

Using the above tables as example, return the following:

+-----------+
| Customers |
+-----------+
| Henry     |
| Max       |
+-----------+


1 # Write your MySQL query statement below
2 SELECT Customers.Name as Customers  FROM Customers where Customers.Id not in (select Orders.CustomerId from Orders)

 

相关文章:

  • 2022-02-13
  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
  • 2021-07-31
  • 2022-12-23
  • 2022-02-28
  • 2021-12-05
猜你喜欢
  • 2021-11-24
  • 2021-05-29
  • 2022-12-23
  • 2021-06-15
  • 2022-12-23
  • 2021-11-19
  • 2022-03-06
相关资源
相似解决方案