mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 03:33:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			67 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			67 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>Table: <code>Customers</code></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
+-------------+---------+
 | 
						|
| Column Name | Type    |
 | 
						|
+-------------+---------+
 | 
						|
| id          | int     |
 | 
						|
| name        | varchar |
 | 
						|
+-------------+---------+
 | 
						|
id is the primary key (column with unique values) for this table.
 | 
						|
Each row of this table indicates the ID and name of a customer.
 | 
						|
</pre>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
 | 
						|
<p>Table: <code>Orders</code></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
+-------------+------+
 | 
						|
| Column Name | Type |
 | 
						|
+-------------+------+
 | 
						|
| id          | int  |
 | 
						|
| customerId  | int  |
 | 
						|
+-------------+------+
 | 
						|
id is the primary key (column with unique values) for this table.
 | 
						|
customerId is a foreign key (reference columns) of the ID from the Customers table.
 | 
						|
Each row of this table indicates the ID of an order and the ID of the customer who ordered it.
 | 
						|
</pre>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
 | 
						|
<p>Write a solution to find all customers who never order anything.</p>
 | 
						|
 | 
						|
<p>Return the result table in <strong>any order</strong>.</p>
 | 
						|
 | 
						|
<p>The result format is in the following example.</p>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong class="example">Example 1:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> 
 | 
						|
Customers table:
 | 
						|
+----+-------+
 | 
						|
| id | name  |
 | 
						|
+----+-------+
 | 
						|
| 1  | Joe   |
 | 
						|
| 2  | Henry |
 | 
						|
| 3  | Sam   |
 | 
						|
| 4  | Max   |
 | 
						|
+----+-------+
 | 
						|
Orders table:
 | 
						|
+----+------------+
 | 
						|
| id | customerId |
 | 
						|
+----+------------+
 | 
						|
| 1  | 3          |
 | 
						|
| 2  | 1          |
 | 
						|
+----+------------+
 | 
						|
<strong>Output:</strong> 
 | 
						|
+-----------+
 | 
						|
| Customers |
 | 
						|
+-----------+
 | 
						|
| Henry     |
 | 
						|
| Max       |
 | 
						|
+-----------+
 | 
						|
</pre>
 |