2022-03-27 20:56:26 +08:00
|
|
|
|
<p><code>Customers</code> 表:</p>
|
|
|
|
|
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<pre>
|
|
|
|
|
+-------------+---------+
|
|
|
|
|
| Column Name | Type |
|
|
|
|
|
+-------------+---------+
|
|
|
|
|
| id | int |
|
|
|
|
|
| name | varchar |
|
|
|
|
|
+-------------+---------+
|
|
|
|
|
在 SQL 中,id 是该表的主键。
|
|
|
|
|
该表的每一行都表示客户的 ID 和名称。</pre>
|
|
|
|
|
|
|
|
|
|
<p><code>Orders</code> 表:</p>
|
|
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
|
+-------------+------+
|
|
|
|
|
| Column Name | Type |
|
|
|
|
|
+-------------+------+
|
|
|
|
|
| id | int |
|
|
|
|
|
| customerId | int |
|
|
|
|
|
+-------------+------+
|
|
|
|
|
在 SQL 中,id 是该表的主键。
|
|
|
|
|
customerId 是 Customers 表中 ID 的外键( Pandas 中的连接键)。
|
|
|
|
|
该表的每一行都表示订单的 ID 和订购该订单的客户的 ID。</pre>
|
|
|
|
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
|
|
|
|
|
<p>找出所有从不点任何东西的顾客。</p>
|
|
|
|
|
|
|
|
|
|
<p>以 <strong>任意顺序</strong> 返回结果表。</p>
|
|
|
|
|
|
|
|
|
|
<p>结果格式如下所示。</p>
|
|
|
|
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
|
|
|
|
|
<p><strong>示例 1:</strong></p>
|
|
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
|
<b>输入:</b>
|
|
|
|
|
Customers table:
|
|
|
|
|
+----+-------+
|
|
|
|
|
| id | name |
|
2022-03-27 20:56:26 +08:00
|
|
|
|
+----+-------+
|
|
|
|
|
| 1 | Joe |
|
|
|
|
|
| 2 | Henry |
|
|
|
|
|
| 3 | Sam |
|
|
|
|
|
| 4 | Max |
|
|
|
|
|
+----+-------+
|
2023-12-09 18:42:21 +08:00
|
|
|
|
Orders table:
|
|
|
|
|
+----+------------+
|
|
|
|
|
| id | customerId |
|
2022-03-27 20:56:26 +08:00
|
|
|
|
+----+------------+
|
|
|
|
|
| 1 | 3 |
|
|
|
|
|
| 2 | 1 |
|
|
|
|
|
+----+------------+
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<b>输出:</b>
|
|
|
|
|
+-----------+
|
2022-03-27 20:56:26 +08:00
|
|
|
|
| Customers |
|
|
|
|
|
+-----------+
|
|
|
|
|
| Henry |
|
|
|
|
|
| Max |
|
2023-12-09 18:42:21 +08:00
|
|
|
|
+-----------+</pre>
|