当前位置:网站首页>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
);
边栏推荐
- [Yu Yue education] Jiujiang University material analysis and testing technology reference
- 树形结构数据的处理
- 网络安全-ACL访问控制列表
- Hard core observation 547 large neural network may be beginning to become aware?
- MySQL learning 03
- In 2022, 95% of the three most common misunderstandings in software testing were recruited. Are you that 5%?
- [leetcode] 797 and 1189 (basis of graph theory)
- 【Camera专题】手把手撸一份驱动 到 点亮Camera
- 疫情當頭,作為Leader如何進行團隊的管理?| 社區征文
- [fluent] fluent debugging (debug debugging window | viewing mobile phone log information | setting normal breakpoints | setting expression breakpoints)
猜你喜欢

树形结构数据的处理

Smart management of Green Cities: Digital twin underground integrated pipe gallery platform

stm32F407-------DMA

Machine learning notes (constantly updating...)

How do it students find short-term internships? Which is better, short-term internship or long-term internship?
![[camera topic] complete analysis of camera dtsi](/img/cb/d42589fcf0610600c9dc8c7992d4d7.png)
[camera topic] complete analysis of camera dtsi

¢ growth path and experience sharing of getting an offer

The testing process that software testers should know
![[shutter] shutter debugging (debugging fallback function | debug method of viewing variables in debugging | console information)](/img/66/0fda43da0d36fc0c9277ca86ece252.jpg)
[shutter] shutter debugging (debugging fallback function | debug method of viewing variables in debugging | console information)

In the face of difficult SQL requirements, HQL is not afraid
随机推荐
Caused by: com. fasterxml. jackson. databind. exc.MismatchedInputException: Cannot construct instance o
可視化yolov5格式數據集(labelme json文件)
Take you ten days to easily complete the go micro service series (II)
小程序开发黑马购物商城中遇到的问题
微信小程序開發工具 POST net::ERR_PROXY_CONNECTION_FAILED 代理問題
ByteDance data Lake integration practice based on Hudi
[camera topic] complete analysis of camera dtsi
Network security - Information Collection
网络安全-ACL访问控制列表
机器学习笔记(持续更新中。。。)
PS remove watermark details
Swift开发学习
File class (check)
Trial setup and use of idea GoLand development tool
Analyzing several common string library functions in C language
How do it students find short-term internships? Which is better, short-term internship or long-term internship?
Huakaiyun | virtual host: IP, subnet mask, gateway, default gateway
Return the only different value (de duplication)
网络安全-扫描
小程序开发的部分功能