Skip to content

Commit dac3e44

Browse files
committed
[LeetCode Sync] Runtime - 459 ms (98.76%), Memory - 0.0B (100.00%)
1 parent 0a849c0 commit dac3e44

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<p>Table: <code>Customers</code></p>
2+
3+
<pre>
4+
+-------------+---------+
5+
| Column Name | Type |
6+
+-------------+---------+
7+
| id | int |
8+
| name | varchar |
9+
+-------------+---------+
10+
id is the primary key (column with unique values) for this table.
11+
Each row of this table indicates the ID and name of a customer.
12+
</pre>
13+
14+
<p>&nbsp;</p>
15+
16+
<p>Table: <code>Orders</code></p>
17+
18+
<pre>
19+
+-------------+------+
20+
| Column Name | Type |
21+
+-------------+------+
22+
| id | int |
23+
| customerId | int |
24+
+-------------+------+
25+
id is the primary key (column with unique values) for this table.
26+
customerId is a foreign key (reference columns) of the ID from the Customers table.
27+
Each row of this table indicates the ID of an order and the ID of the customer who ordered it.
28+
</pre>
29+
30+
<p>&nbsp;</p>
31+
32+
<p>Write a solution to find all customers who never order anything.</p>
33+
34+
<p>Return the result table in <strong>any order</strong>.</p>
35+
36+
<p>The result format is in the following example.</p>
37+
38+
<p>&nbsp;</p>
39+
<p><strong class="example">Example 1:</strong></p>
40+
41+
<pre>
42+
<strong>Input:</strong>
43+
Customers table:
44+
+----+-------+
45+
| id | name |
46+
+----+-------+
47+
| 1 | Joe |
48+
| 2 | Henry |
49+
| 3 | Sam |
50+
| 4 | Max |
51+
+----+-------+
52+
Orders table:
53+
+----+------------+
54+
| id | customerId |
55+
+----+------------+
56+
| 1 | 3 |
57+
| 2 | 1 |
58+
+----+------------+
59+
<strong>Output:</strong>
60+
+-----------+
61+
| Customers |
62+
+-----------+
63+
| Henry |
64+
| Max |
65+
+-----------+
66+
</pre>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Write your MySQL query statement below
2+
SELECT name AS Customers
3+
FROM Customers
4+
LEFT JOIN Orders ON Orders.customerId = Customers.id
5+
WHERE Orders.id is null

0 commit comments

Comments
 (0)