# 编写 SQL 语句,组合 Products 表中的产品名称(prod_name)和 Customers 表中的顾客名称(cust_name)并返回,然后按产品名称对结果进行升序排序。
# 按列组合  使用 union
select prod_name 
from Products 
union 
select cust_name as prod_name
from Customers 
order by prod_name;



关键词:union

用法:

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