题解 | SQL49#组合 Products 表中的产品名称和 Customers 表中的顾客名称#

组合 Products 表中的产品名称和 Customers 表中的顾客名称

http://www.nowcoder.com/practice/461077c0ba0f473abecf5ee79c632acd

分析

关键词:union

用法:

  • union--连接表,对行操作。
  • union--将两个表做行拼接,同时自动删除重复的行。
  • union all---将两个表做行拼接,保留重复的行

代码

select prod_name from Products
union 
select cust_name as prod_name from Customers
order by prod_name
全部评论

相关推荐

04-13 20:21
门头沟学院 Java
点赞 评论 收藏
分享
评论
41
8
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务