当前位置:网站首页>Leetcode 183 Customers who never order (2022.07.02)
Leetcode 183 Customers who never order (2022.07.02)
2022-07-03 02:01: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')
A website contains two tables ,Customers Table and Orders surface . Write a SQL Inquire about , Find all customers who never order anything .
Customers surface :
±—±------+
| Id | Name |
±—±------+
| 1 | Joe |
| 2 | Henry |
| 3 | Sam |
| 4 | Max |
±—±------+
Orders surface :
±—±-----------+
| Id | CustomerId |
±—±-----------+
| 1 | 3 |
| 2 | 1 |
±—±-----------+
For example, given the above table , Your query should return :
±----------+
| Customers |
±----------+
| Henry |
| Max |
±----------+
source : Power button (LeetCode)
link :https://leetcode.cn/problems/customers-who-never-order
Method 1 :NOT IN Words and expressions
MySQL Submission :
select customers.name as 'Customers'
from customers
where customers.id not in
(
select customerid from orders
);
边栏推荐
- Custom components, using NPM packages, global data sharing, subcontracting
- Ni visa fails after LabVIEW installs the third-party visa software
- Button button adaptive size of wechat applet
- Deep learning notes (constantly updating...)
- Network security - Trojan horse
- How is the mask effect achieved in the LPL ban/pick selection stage?
- 网络安全-密码破解
- 自定义组件、使用npm包、全局数据共享、分包
- In 2022, 95% of the three most common misunderstandings in software testing were recruited. Are you that 5%?
- Modify table structure
猜你喜欢
stm32F407-------ADC
mysql
Certaines fonctionnalités du développement d'applets
NCTF 2018 part Title WP (1)
可視化yolov5格式數據集(labelme json文件)
深度学习笔记(持续更新中。。。)
What are the key points often asked in the redis interview
[data mining] task 4:20newsgroups clustering
可视化yolov5格式数据集(labelme json文件)
Visualisation de l'ensemble de données au format yolov5 (fichier labelme json)
随机推荐
【Camera专题】手把手撸一份驱动 到 点亮Camera
File class (add / delete)
es6 filter() 数组过滤方法总结
Query product cases - page rendering data
苏世民:25条工作和生活原则
网络安全-防火墙
Network security - dynamic routing protocol rip
疫情當頭,作為Leader如何進行團隊的管理?| 社區征文
网络安全-密码破解
网络安全-最简单的病毒
Network security NAT network address translation
Socket编程
微信小程序開發工具 POST net::ERR_PROXY_CONNECTION_FAILED 代理問題
疫情当头,作为Leader如何进行团队的管理?| 社区征文
Performance test | script template sorting, tool sorting and result analysis
小程序開發的部分功能
Where is the future of test engineers? Confused to see
微信小程序开发工具 POST net::ERR_PROXY_CONNECTION_FAILED 代理问题
"Jetpack - livedata parsing"
去除网页滚动条方法以及内外边距