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 |
+-----------+
 # Write your MySQL query statement below
SELECT Customers.Name as Customers FROM Customers where Customers.Id not in (select Orders.CustomerId from Orders)

LeeCode(Database)-Customers Who Never Order的更多相关文章

  1. DataBase -- Customers Who Never Order

    Question: Suppose that a website contains two tables, the Customers table and the Orders table. Writ ...

  2. [LeetCode] Customers Who Never Order 从未下单订购的顾客

    Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL qu ...

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

    Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL qu ...

  4. 【SQL】183. Customers Who Never Order

    Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL qu ...

  5. LeetCode - Customers Who Never Order

    Description: Suppose that a website contains two tables, the Customers table and the Orders table. W ...

  6. 183. Customers Who Never Order

    Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL qu ...

  7. Customers Who Never Order

    Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL qu ...

  8. 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 ...

  9. 分别针对Customers表与Order表的通用查询操作

    1.针对customers表通用的查询操作 CustomerForQuery package com.aff.PreparedStatement; import java.lang.reflect.F ...

随机推荐

  1. jquery datepicker日期控件用法

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.c ...

  2. qcow2 raw vhd 虚拟磁盘转换

    Centos-6.4-x86_64_Ruiy.vhd: Microsoft Disk Image, Virtual Server or Virtual PC

  3. 本地存储组件--兼容IE低版本

        在前端开发过程中,会用到本地缓存,但是由于浏览器对不同规范支持的程度不一样,每次进行使用都要为兼容行花费不少时间.我整理了一个本地存储的组件.     组件特点: 可以配置使用localSto ...

  4. LVM(2)逻辑卷的扩展、缩减、快照卷

    一.扩展逻辑卷:lvextend   扩展逻辑卷物理边界    -L [+]# /PATH/TO/LV2G, +3G5G

  5. Deep Compression Compressing Deep Neural Networks With Pruning, Trained QuantizationAnd Huffman Coding

    转载请注明出处: http://www.cnblogs.com/sysuzyq/p/6200613.html by 少侠阿朱

  6. linux 常用 命令 笔记二

    wget 下载,得到网络上的内容 grep 文件搜索工具 EveryThing is a file in the linux system 安装 cowsay sudo apt-get install ...

  7. python-布尔值

    布尔只有两个值:0,1 1或0 真或假 下面的值在作为布尔表达式的时候,会被解释器看作假(false) False    None    0   ""    ()    []   ...

  8. 【js】判断设备类型,访问相应的网站

    引入 function uaredirect(f) { try { if (document.getElementById("bdmark") != null) { return ...

  9. Android----------eclipse常用快捷键

    类级操作:--------------------一个去包,一个导包------------------------------------ Ctrl+shift+O (不是零) 清除没用引用 ctr ...

  10. NOT 运算符

    NOT运算符不是独立的,它是一个可以放在任何逻辑表达式前面的修饰符,能得到与结果相反的结果.所以,如果一个表达式是真,就会得到假:如果是假,就会得到真.有时测试查找条件的反面更容易.不过,NOT运算符 ...