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. SQL:define和verify命令及替换变量&

    =================替换变量&===============使用一个&符号来指定一个变量值,执行SQL语句时,会提示用户输入一个数值. SQL> select sa ...

  2. SOLR使用手册之操作collection

    一.Collections API  参考:https://cwiki.apache.org/confluence/display/solr/Collections+API 因为API比较多,我就不一 ...

  3. EasyuiCombobox三级联动

    有许多刚接触Easyui中Combobox控件的朋友可能都会遇到的问题:如何将Combobox做成三级联动? 先本人有个三级联动的案例给大家参考参考,经测试能通过.注意Combobox绑定的数据是Js ...

  4. Eclipse error:Access restriction

    报错:Access restriction: The method decodeBuffer(String) from the type CharacterDecoder is not accessi ...

  5. Thread was being aborted.你遇到了吗?

    这个Exception目前了解到的有两个原因造成:        1.Reponse.Write的问题(目前网上找到的信息十有八九都讲的是这个问题)      2.Web.Config中设定的exec ...

  6. Webfrom基础知识

    MyBeNASP.NET内置对象 (1)简述ASP.NET内置对象. 答:ASP.NET提供了内置对象有Page.Request.Response.Application.Session.Server ...

  7. (转) 学习C++ -> 类(Classes)的定义与实现

    学习C++ -> 类(Classes)的定义与实现 一."类" 的介绍    在C++中, 用 "类" 来描述 "对象", 所谓的&q ...

  8. 关于取数组地址的识记(&s+1,s+1,&s[0]+1)

    #include <stdio.h> #include <malloc.h> int main() { ', 'o'}; ); printf(]); ]+); printf(] ...

  9. YUI的类型判断函数

    1.首先定义一个关于类型的对象,及相关变量 类型判断对象 ar L = Y.Lang || (Y.Lang = {}), STRING_PROTO = String.prototype, TOSTRI ...

  10. Hibernate中HQL的日期差值计算,可计算相差多少秒

    最近有个业务需求就是计算订单创建时间离现在超过 4 小时的订单都查找出来! 那么就需要用到日期函数了. 网上找了一下总共的日期函数有一下几个: CURRENT_DATE() 返回数据库当前日期 时间函 ...