国产探花免费观看_亚洲丰满少妇自慰呻吟_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;


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 华蓥市| 连城县| 凤庆县| 百色市| 元谋县| 琼结县| 通渭县| 日土县| 天长市| 崇明县| 徐州市| 逊克县| 三江| 宜黄县| 温州市| 东明县| 湛江市| 象州县| 楚雄市| 沾化县| 牡丹江市| 龙海市| 和林格尔县| 县级市| 伊吾县| 息烽县| 莲花县| 威远县| 大庆市| 平果县| 拉萨市| 瑞安市| 淳安县| 延津县| 芒康县| 保康县| 宣城市| 平凉市| 江都市| 武鸣县| 磴口县|