[LeetCode]-DataBase-Customers Who Never Order
Suppose that a website contains two tables, the Customers
table and the Orders
table. Write a SQL query to find all customers who never order anything.
Table: Customers
.
+----+-------+
| Id | Name |
+----+-------+
| 1 | Joe |
| 2 | Henry |
| 3 | Sam |
| 4 | Max |
+----+-------+
Table: Orders
.
+----+------------+
| Id | CustomerId |
+----+------------+
| 1 | 3 |
| 2 | 1 |
+----+------------+
Using the above tables as example, return the following:
+-----------+
| Customers |
+-----------+
| Henry |
| Max |
+-----------+ 需求:查询没下单的客户 查询:
CREATE TABLE Customers(
Id TINYINT UNSIGNED,
Name VARCHAR(20)
)ENGINE=MyISAM CHARSET=utf8;
CREATE TABLE Orders(
Id TINYINT UNSIGNED,
CustomerId TINYINT UNSIGNED
)ENGINE=MyISAM CHARSET=utf8;
SELECT t1.Name
FROM Customers t1
WHERE NOT EXISTS(
SELECT * FROM Orders t2 WHERE t2.CustomerId=t1.Id
)
[LeetCode]-DataBase-Customers Who Never Order的更多相关文章
- LeeCode(Database)-Customers Who Never Order
Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL qu ...
- DataBase -- Customers Who Never Order
Question: Suppose that a website contains two tables, the Customers table and the Orders table. Writ ...
- LeetCode 183. Customers Who Never Order (从不订购的客户)
题目标签: 题目给了我们 Customers 和 Orders 两个表格,让我们找到 从没订购过的客户. 首先从Orders 得到 订购过的CustomerId,然后再去Customers 里找 没有 ...
- leetcode 183. Customers Who Never Order
select Name as Customers from Customers where Id not in (select CustomerId from Orders);
- [LeetCode] Customers Who Never Order 从未下单订购的顾客
Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL qu ...
- LeetCode - Customers Who Never Order
Description: Suppose that a website contains two tables, the Customers table and the Orders table. W ...
- LeetCode——Customers Who Never Order(灵活使用NOT IN以及IN)
Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL qu ...
- [SQL]LeetCode183. 从不订购的客户 | Customers Who Never Order
Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL qu ...
- LeetCode Database题解
175. Combine Two Tables 使用外连接即可. # Write your MySQL query statement below select FirstName, LastName ...
- [LeetCode] 429. N-ary Tree Level Order Traversal_ Easy
Given an n-ary tree, return the level order traversal of its nodes' values. (ie, from left to right, ...
随机推荐
- 最长不下降/不上升子序列&&最长上升/下降子序列
最长不下降/不上升子序列&&最长上升/下降子序列 struct cmp1{bool operator()(int a,int b){return a>b;}}; int main ...
- centos7搭建单机redis5.0
目录 1. redis初步安装 2. 配置 3. 设置开机启动(centos6) 3.1 编写启动脚本 3.2 设置权限 3.3 启动测试 3.4 设置开机自启动 4. 设置开机启动(centos7) ...
- python-day2(学前了解)
编程语言分类 编程语言是用来和计算机交互的,但计算机只认识0和1 机器语言(低级语言) 直接和硬件交互 用0和1和计算机交流 优点:执行效率高 缺点:开发效率低 汇编语言 直接和硬件交互 优点:开发效 ...
- H. A Cache Simulator
Cache memories have been used widely in current microprocessor systems. In this problem, you are ask ...
- go语言中os/signal包的学习与使用
package main; import ( "os" "os/signal" "fmt" ) //signal包中提供了两个函数 //No ...
- 在Linux上安装tomcat和JDK
1.tomcat的安装 a.#cd download(进入download文件夹) b.#wget http://111.23.5.142:82/mirrors.hust.edu.cn/apache/ ...
- docker inspect命令查看镜像详细信息
使用 inspect 命令查看镜像详细信息,包括制作者.适应架构.各层的数字摘要等. # docker inspect --help Usage: docker inspect [OPTIONS] N ...
- Verilog中的Timescale作用
很多时候,我们拿到已有的东西理所当然的用了,其实,你真的对你所使用的东西了解吗? 再次犯下这样的错误,是因为在把代码从Altera 的CycloneV移植到Xilinx的Spartan6上,我遇到了非 ...
- python-文件的修改
python-文件的修改 修改文件的方法 第一种方法: 第二种方法: f=open("my-heart","r") f_new=open("my-he ...
- 接口测试断言详解(Jmeter)
接口测试是目前最主流的自动化测试手段,它向服务器发送请求,接收和解析响应结果,通过验证响应报文是否满足需求规约来验证系统逻辑正确性.接口的响应类型通过Content-Type指定,常见的响应类型有: ...