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. C# WEB API ApiController 修改response header contentType

    var res = Request.CreateResponse(HttpStatusCode.OK, file); res.Content.Headers.ContentType = new Med ...

  2. SoftLayerDebug

  3. Qt之模型/视图(委托)

    # -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.Qt import * from PyQt4. ...

  4. View中取设置了Tag的UILabel

    UILabel *badge = (UILabel *)[self.view viewWithTag:];

  5. 详细解读Jquery各Ajax函数:$.get(),$.post(),$.ajax(),$.getJSON() —(转)

    一,$.get(url,[data],[callback]) 说明:url为请求地址,data为请求数据的列表(是可选的,也可以将要传的参数写在url里面),callback为请求成功后的回调函数,该 ...

  6. CodeForces 158 B. Taxi(模拟)

    [题目链接]click here~~ [题目大意]n组团体去包车,每组团体的人数<=4,一辆车最多容纳4人,求所求车的数目最小 [解题思路]:思路见代码~~ // C #ifndef _GLIB ...

  7. openldap---ldapsearch使用

    ldapsearch 參数表 下表描写叙述能够用于 ldapsearch 的区分大写和小写的參数. 參数 用途 -? 打印关于使用 ldapsearch 的帮助. -a deref 指定别名反向引用. ...

  8. 解决getJdbcTemplate往oracle数据库中插入数据返回主键出错问题

    我们使用Spring中的JdbcDaoSupport往Mysql中插入数据并返回主键代码,我们使用的mysql数据库,主键在数据库中设置为自增长:该类继承自JdbcDaoSupport,所以能直接使用 ...

  9. VS2008下编译boost_1_47_0

      1,boost下载 如果不想自己编译,可下载http://boostpro.com/download/boost_1_47_setup.exe,安装后,程序会提供选项供下载已经编译好的库文件,基于 ...

  10. [HeadFist-HTMLCSS学习笔记][第五章认识媒体]

    图像格式 PNG 多种颜色透明 无损压缩 PNG-8,PNG-16,PNG-32 多用于logo GIF 动画 256色 无损 JPEG 不能透明 多用于照片 img URL能插入 alt属性 = 如 ...