File tree Expand file tree Collapse file tree 2 files changed +71
-0
lines changed
Solutions/0183-customers-who-never-order Expand file tree Collapse file tree 2 files changed +71
-0
lines changed Original file line number Diff line number Diff line change 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 >  ; </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 >  ; </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 >  ; </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 >
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments