住房城乡建设部办公厅网站,网站要跟换域名怎么做,定襄网站建设,天津企业网站模板建站哪家好★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号#xff1a;山青咏芝#xff08;shanqingyongzhi#xff09;➤博客园地址#xff1a;山青咏芝#xff08;https://www.cnblogs.com/strengthen/#xff09;➤GitHub地址山青咏芝shanqingyongzhi➤博客园地址山青咏芝https://www.cnblogs.com/strengthen/➤GitHub地址https://github.com/strengthen/LeetCode➤原文地址https://www.cnblogs.com/strengthen/p/9720985.html ➤如果链接不是山青咏芝的博客园地址则可能是爬取作者的文章。➤原文已修改更新强烈建议点击原文地址阅读支持作者支持原创★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★ 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 |
----------- 某网站包含两个表Customers 表和 Orders 表。编写一个 SQL 查询找出所有从不订购任何东西的客户。 Customers 表 -----------
| Id | Name |
-----------
| 1 | Joe |
| 2 | Henry |
| 3 | Sam |
| 4 | Max |
-----------Orders 表 ----------------
| Id | CustomerId |
----------------
| 1 | 3 |
| 2 | 1 |
----------------例如给定上述表格你的查询应返回 -----------
| Customers |
-----------
| Henry |
| Max |
----------- 方法使用子查询和NOT IN子句 算法如果我们有一个订购过的客户列表很容易知道谁从未订购过。 我们可以使用以下代码来获取此类列表。 select customerid from orders; 然后我们可以NOT IN用来查询不在此列表中的客户。 1 select customers.name as Customers
2 from customers
3 where customers.id not in
4 (
5 select customerid from orders
6 ); 222ms 1 # Write your MySQL query statement below
2 SELECT Name as Customers from Customers where Id not in (select CustomerId from Orders) 转载于:https://www.cnblogs.com/strengthen/p/9720985.html