Examly題庫
國家安全情報人員考試五等考試-資訊組資料處理大意108 年第 2 題單選題

select c_name, city from customer inner join sales using (s_id) where sales.lname = 'Tom'; 下列那個SQL指令可和上述SQL指令得到相同的查詢結果?

Aselect c_name, city from customer inner join sales having customer.s_id =sales.s_id and sales.lname='Tom';
Bselect c_name, city from customer where customer.s_id =sales.s_id and sales.lname='Tom';
Cselect c_name, city from customer, sales where sales.lname='Tom';
Dselect c_name, city from customer, sales where customer.s_id =sales.s_id and sales.lname='Tom';正確答案
答案與詳解
D
正確答案
INNER JOIN USING(s_id) 等同於在 WHERE 子句寫 customer.s_id = sales.s_id 的隱式連接。

逐選項解析

Aselect c_name, city from customer inner join sales having customer.s_id =sales.s_id and sales.lname='Tom';✕ 易錯陷阱
HAVING 用於 GROUP BY 後的群組篩選,不能用來寫連接條件。此處應該用 ON 或 WHERE,語法錯誤。
Bselect c_name, city from customer where customer.s_id =sales.s_id and sales.lname='Tom';✕ 錯誤
FROM 子句只有 customer 一個表,卻在 WHERE 引用 sales.s_id,語法錯誤(找不到 sales 表)。
Cselect c_name, city from customer, sales where sales.lname='Tom';✕ 易錯陷阱
Dselect c_name, city from customer, sales where customer.s_id =sales.s_id and sales.lname='Tom';✓ 正確

立即註冊,看完整詳解

這題的完整詳解,註冊就能看 · 每天 2 題免費

精選詳解
  • 完整逐選項解析
  • 秒殺解題技巧與破題關鍵
  • 關鍵知識表整理
  • 陷阱與易錯提醒
  • 同考點歷屆題庫連續刷題與錯題本
接著練習整份考卷查看 108 年 國家安全情報人員考試五等考試-資訊組《資料處理大意》完整試題與解答

同科目歷年考卷

資料處理大意 相關題目

想練更多資料處理大意考古題?

Examly 收錄 50 萬+ 道歷屆題目,每題都有像這樣的精選詳解。免費下載,立即開練。

Examly