题解 | #返回顾客名称和相关订单号#
返回顾客名称和相关订单号
http://www.nowcoder.com/practice/7e7bc361db6a4cb6aa35eefccfe75364
# 返回 Customers 表中的顾客名称(cust_name)和Orders 表中的相关订单号(order_num), # 并按顾客名称再按订单号对结果进行升序排序。 # 你可以尝试用两个不同的写法,一个使用简单的等联结语法,另外一个使用 INNER JOIN。 # 1 inner join # select cust_name,order_num # from Customers inner join Orders # on Orders.cust_id = Customers.cust_id # order by cust_name; # 2简单的等链接语法 select cust_name,( select order_num from Orders where Customers.cust_id = Orders.cust_id ) from Customers order by cust_name;