当前位置:网站首页>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
);
边栏推荐
猜你喜欢

详细些介绍如何通过MQTT协议和华为云物联网进行通信

mysql

【Camera专题】手把手撸一份驱动 到 点亮Camera
![[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)
![[data mining] task 1: distance calculation](/img/72/a63cdfe32a7c438acf48a069d9bba1.png)
[data mining] task 1: distance calculation

Ni visa fails after LabVIEW installs the third-party visa software

PS去除水印详解

PS remove watermark details

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

His experience in choosing a startup company or a big Internet company may give you some inspiration
随机推荐
Modify table structure
When the epidemic comes, how to manage the team as a leader| Community essay solicitation
Network security - the simplest virus
详细些介绍如何通过MQTT协议和华为云物联网进行通信
[data mining] task 3: decision tree classification
Depth (penetration) selector:: v-deep/deep/ and > > >
[leetcode] 797 and 1189 (basis of graph theory)
Network security - firewall
File class (add / delete)
In the face of difficult SQL requirements, HQL is not afraid
[shutter] hero animation (hero realizes radial animation | hero component createrecttween setting)
树形结构数据的处理
深度学习笔记(持续更新中。。。)
Comment le chef de file gère - t - il l'équipe en cas d'épidémie? Contributions communautaires
Anna: Beibei, can you draw?
Learn BeanShell before you dare to say you know JMeter
502 (bad gateway) causes and Solutions
stm32F407-------DMA
How do it students find short-term internships? Which is better, short-term internship or long-term internship?
Wechat applet Development Tool Post net:: Err Proxy Connexion Problèmes d'agent défectueux