国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

183. Customers Who Never Order

2024-07-21 02:52:32
字體:
來源:轉載
供稿:網友

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中某一類name顯示出來,這個條件通過Orders判斷。

可以通過left join將Customers與Orders連接起來,然后篩選出符合條件的。

以例題為例:

Customers left join Orders的結果:

條件是:沒有訂單的顧客的名字,表示為CustomerId is NULL;

select Customers.Name as Customersfrom Customers left join Orderson Customers.Id=Orders.CustomerIdwhere Orders.CustomerId is NULL;


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 思茅市| 拜泉县| 越西县| 龙川县| 郴州市| 天门市| 梅河口市| 普宁市| 陵川县| 墨脱县| 南皮县| 鄱阳县| 普兰店市| 廉江市| 平利县| 射阳县| 浦城县| 万州区| 芜湖市| 磐石市| 教育| 昆明市| 金华市| 通州区| 武汉市| 福建省| 工布江达县| 宣武区| 大兴区| 陵川县| 交口县| 成武县| 新竹县| 大英县| 景宁| 潼南县| 景德镇市| 阿克| 娄底市| 高碑店市| 衢州市|