题目:
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 |
+———–+

Answer:
思路:NOT IN用法

SELECT`Name` AS 'Customers'
FROMcustomers
WHEREId NOT IN ( SELECT CustomerId FROM orders )

LeetCode:183.Customers Who Never Order相关推荐

  1. LeetCode: 183. Customers Who Never Order

    LeetCode: 183. Customers Who Never Order 题目描述 Suppose that a website contains two tables, the Custom ...

  2. leetcode 183. Customers Who Never Order

    题意:查找没有点过单的客人 题目链接:https://leetcode.com/problems/customers-who-never-order/ select Name from Custome ...

  3. Leetcode#183. Customers Who Never Order

    题目描述:查找没有预定(orders)的顾客(customers) 普通方法: select Name as Customers from Customers c where c.Id not in ...

  4. 183. Customers Who Never Order

    原题链接:https://leetcode.com/problems/customers-who-never-order/description/ 做完这道题目我才发现,我跟不就不懂 in, exis ...

  5. 183. Customers Who Never Order没有下过订单的顾客MySQL

    假设一个网站包含两个表,Customers表和Orders表.编写SQL查询以查找所有没订购任何商品的客户. customers orders Output 用到left  outer join: s ...

  6. 【Leetcode】Customers Who Never Order

    题目链接:https://leetcode.com/problems/customers-who-never-order/ 题目: Suppose that a website contains tw ...

  7. [SQL]LeetCode183. 从不订购的客户 | Customers Who Never Order

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★ ➤微信公众号:山青咏芝(shanqingyongzhi) ➤博客园地址:山青咏芝(https://www.cnblog ...

  8. LeetCode 103. Binary Tree Zigzag Level Order Traversal

    LeetCode 103. Binary Tree Zigzag Level Order Traversal Solution1:基于层次遍历的微改 /*** Definition for a bin ...

  9. LeetCode:汇总区间【228】

    LeetCode:汇总区间[228] 题目描述 给定一个无重复元素的有序整数数组,返回数组区间范围的汇总. 示例 1: 输入: [0,1,2,4,5,7] 输出: ["0->2&quo ...

最新文章

  1. 双系统Ubuntu无法进入Windows磁盘的解决方法
  2. 华中科技大学计算机科学卓越班,2016年华中科技大学光电信息科学与工程(卓越计划实验班)专业在江苏录取分数线...
  3. 删除链表最小节点c语言,最简单的链表删除第一个节点时释放内存的问题
  4. ubuntu18.04(python3.6)安装pip3报错:ImportError: cannot import name 'sysconfig'
  5. C和C++的区别 04.函数重载
  6. gcc 优化选项 -O1 -O2 -O3 -Os 优先级
  7. 西安电子科技大学计算机接口与通用技术答案,西安电子科技大学--西电《计算机接口与通信技术》平时作业...
  8. maven 之 setting.xm 的配置详解、说明
  9. 【动画技巧】GIF动画转SWF小技巧
  10. [Erlang危机](4.4)命名管道
  11. 【网络信息安全】授权与访问控制
  12. SpringAOP导致@Autowired依赖注入失败
  13. matlab中三维非线性拟合,matlab非线性拟合与绘制三维曲面
  14. 【Matlab故障诊断分析】BP神经网络三相逆变器故障诊断研究【含源码 1736期】
  15. 微信小程序 input隐藏和不可操作的设置
  16. 无法加入域,隶属于域,工作组选项为灰色
  17. 一问解决设备管理器里面提示:未知usb设备(设备描述符请求失败) 或者是“Unknown USB Device(Device Descriptor Request Sailed)”错误
  18. swift方法顺序 不成文规定
  19. 茜茜:大二开始布局学习大数据,结果如何?
  20. Lucene.net和盘古分词使用小结

热门文章

  1. Debian搭建Samba服务
  2. C语言从入门到入土(三)
  3. 机器学习——不可逆矩阵处理
  4. 使用公开页实现扫码签到功能
  5. C语言---1 C语言认知
  6. flink 1.14编译:flink-fs-hadoop-shaded找不到
  7. 一名大二废柴今后目标
  8. 利用PCL库做简单的三维立体图形
  9. C --cp2 类似cat工具的小程序。
  10. 电信物联网平台ctwing对接开发-平台概述