当前位置:网站首页>力扣(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
);
边栏推荐
- [fluent] hero animation (hero animation use process | create hero animation core components | create source page | create destination page | page Jump)
- Network security NAT network address translation
- [AUTOSAR cantp] -2.11-uds diagnostic response frame data segment data padding data filling and data optimization data optimization (Theory + configuration)
- Reprint some Qt development experience written by great Xia 6.5
- 网络安全-病毒
- Network security - scan
- 网络安全-NAT网络地址转换
- Storage basic operation
- 网络安全-木马
- 可視化yolov5格式數據集(labelme json文件)
猜你喜欢
Visualisation de l'ensemble de données au format yolov5 (fichier labelme json)
Certaines fonctionnalités du développement d'applets
[error record] an error is reported in the fluent interface (no mediaquery widget ancestor found. | scaffold widgets require a mediaquery)
[data mining] task 1: distance calculation
How is the mask effect achieved in the LPL ban/pick selection stage?
【Camera专题】OTP数据如何保存在自定义节点中
[error record] navigator operation requested with a context that does not include a naviga
Take you ten days to easily complete the go micro service series (II)
PS去除水印详解
Bottleneck period must see: how can testers who have worked for 3-5 years avoid detours and break through smoothly
随机推荐
【Camera专题】手把手撸一份驱动 到 点亮Camera
小程序开发的部分功能
Redis: simple use of redis
[data mining] task 1: distance calculation
Certaines fonctionnalités du développement d'applets
疫情当头,作为Leader如何进行团队的管理?| 社区征文
Network security - man in the middle attack
机器学习笔记(持续更新中。。。)
[fluent] hero animation (hero animation use process | create hero animation core components | create source page | create destination page | page Jump)
Network security - scanning and password explosion 2
[error record] navigator operation requested with a context that does not include a naviga
自定义组件、使用npm包、全局数据共享、分包
Network security - cracking system passwords
[Appendix 6 Application of reflection] Application of reflection: dynamic agent
[error record] an error is reported in the fluent interface (no mediaquery widget ancestor found. | scaffold widgets require a mediaquery)
网络安全-浅谈安全威胁
A simple tool for analyzing fgui dependencies
STM32 - introduction of external interrupts exti and NVIC
String splicing function of MySQL
Problems encountered in small program development of dark horse shopping mall