当前位置:网站首页>力扣(LeetCode)183. 从不订购的客户(2022.07.02)
力扣(LeetCode)183. 从不订购的客户(2022.07.02)
2022-07-03 01:32:00 【ChaoYue_miku】
Create table If Not Exists Customers (id int, name varchar(255))
Create table If Not Exists Orders (id int, customerId int)
Truncate table Customers
insert into Customers (id, name) values ('1', 'Joe')
insert into Customers (id, name) values ('2', 'Henry')
insert into Customers (id, name) values ('3', 'Sam')
insert into Customers (id, name) values ('4', 'Max')
Truncate table Orders
insert into Orders (id, customerId) values ('1', '3')
insert into Orders (id, customerId) values ('2', '1')
某网站包含两个表,Customers 表和 Orders 表。编写一个 SQL 查询,找出所有从不订购任何东西的客户。
Customers 表:
±—±------+
| Id | Name |
±—±------+
| 1 | Joe |
| 2 | Henry |
| 3 | Sam |
| 4 | Max |
±—±------+
Orders 表:
±—±-----------+
| Id | CustomerId |
±—±-----------+
| 1 | 3 |
| 2 | 1 |
±—±-----------+
例如给定上述表格,你的查询应返回:
±----------+
| Customers |
±----------+
| Henry |
| Max |
±----------+
来源:力扣(LeetCode)
链接:https://leetcode.cn/problems/customers-who-never-order
方法一:NOT IN字句
MySQL提交内容:
select customers.name as 'Customers'
from customers
where customers.id not in
(
select customerid from orders
);
边栏推荐
- 自定义组件、使用npm包、全局数据共享、分包
- Depth (penetration) selector:: v-deep/deep/ and > > >
- In the face of difficult SQL requirements, HQL is not afraid
- Introduction to kotlin collaboration
- 网络安全-破解系统密码
- Rockchip3399 start auto load driver
- 小程序开发黑马购物商城中遇到的问题
- "Jetpack - livedata parsing"
- When the epidemic comes, how to manage the team as a leader| Community essay solicitation
- Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance o
猜你喜欢

View of MySQL

One of the C language practical projects is greedy snake

Everything file search tool

Take you ten days to easily complete the go micro service series (I)

Vant implements a simple login registration module and a personal user center

NCTF 2018 part Title WP (1)
![[North Asia data recovery] data recovery case of raid crash caused by hard disk disconnection during data synchronization of hot spare disk of RAID5 disk array](/img/2a/98400b0d0b5eda1e52abae30746f2b.jpg)
[North Asia data recovery] data recovery case of raid crash caused by hard disk disconnection during data synchronization of hot spare disk of RAID5 disk array

MySQL学习03
![[data mining] task 4:20newsgroups clustering](/img/76/af1d1338c468ec4825fe12816b84ff.png)
[data mining] task 4:20newsgroups clustering

Tâche 6: regroupement DBSCAN
随机推荐
One of the C language practical projects is greedy snake
Wordinsert formula /endnote
2022-02-15 reading the meta module inspiration of the influxdb cluster
网络安全-病毒
Huakaiyun (Zhiyin) | virtual host: what is a virtual host
NCTF 2018 part Title WP (1)
【Camera专题】手把手撸一份驱动 到 点亮Camera
Why can't the start method be called repeatedly? But the run method can?
Network security - talking about security threats
Network security - DNS spoofing and phishing websites
Virtual list
网络安全-ACL访问控制列表
Network security - phishing
网络安全-木马
PS去除水印详解
Swift开发学习
Network security - password cracking
Introduction to kotlin collaboration
【数据挖掘】任务3:决策树分类
Take you ten days to easily complete the go micro service series (II)