一、原题
二、题目翻译
三、题目解析
View the Exhibits and examine the structures of the CUSTOMERS, SALES, and COUNTRIES tables.
(表结构图位置)
You need to generate a report that shows all country names, with corresponding customers (if any) and sales details (if any), for all customers.
Which FROM clause gives the required result?
A. FROM sales JOIN customers USING (cust_id)
FULL OUTER JOIN countries USING (country_id);
B. FROM sales JOIN customers USING (cust_id)
RIGHT OUTER JOIN countries USING (country_id);
C. FROM customers LEFT OUTER JOIN sales USING (cust_id)
RIGHT OUTER JOIN countries USING (country_id);
D. FROM customers LEFT OUTER JOIN sales USING (cust_id)
LEFT OUTER JOIN countries USING (country_id);
答案:C
(在上面表结构图的位置,应该是放几张表的结构图,但是题库上缺了,在网上找了好久,也没有找到)
(表结构图位置)
You need to generate a report that shows all country names, with corresponding customers (if any) and sales details (if any), for all customers.
Which FROM clause gives the required result?
A. FROM sales JOIN customers USING (cust_id)
FULL OUTER JOIN countries USING (country_id);
B. FROM sales JOIN customers USING (cust_id)
RIGHT OUTER JOIN countries USING (country_id);
C. FROM customers LEFT OUTER JOIN sales USING (cust_id)
RIGHT OUTER JOIN countries USING (country_id);
D. FROM customers LEFT OUTER JOIN sales USING (cust_id)
LEFT OUTER JOIN countries USING (country_id);
答案:C
(在上面表结构图的位置,应该是放几张表的结构图,但是题库上缺了,在网上找了好久,也没有找到)
二、题目翻译
查看 CUSTOMERS, SALES, and COUNTRIES表的结构。
要生成一个报表,显示所有客户的所有country names,对应的customers(如果有)和sales details(如果有))
下面哪个from子句,能得出所需的结果?
要生成一个报表,显示所有客户的所有country names,对应的customers(如果有)和sales details(如果有))
下面哪个from子句,能得出所需的结果?
三、题目解析
根据题意要求,要求显示所有的用户的国家名称,而相匹配的用户名和销售信息有可能有,也有可能没有,即为null也要显示,
所以客户表和销售表左连接,显示所有的用户,不管有没有销售信息匹配,然后再用右连接,关联countries表,这样显示所有的country name,不管有没有客户匹配上,或是销售信息匹配上,都显示出来。
表连接的用法,详见:
http://blog.csdn.net/holly2008/article/details/25704471
所以客户表和销售表左连接,显示所有的用户,不管有没有销售信息匹配,然后再用右连接,关联countries表,这样显示所有的country name,不管有没有客户匹配上,或是销售信息匹配上,都显示出来。
表连接的用法,详见:
http://blog.csdn.net/holly2008/article/details/25704471