首页 > 试题广场 >

49.组合 Products 表中的产品名称和 Custom

[单选题]
49.组合 Products 表中的产品名称和 Customers 表中的顾客名称
Products表含有字段prod_name代表产品名称
prod_name
flower
rice
ring
umbrella
Customers表代表顾客信息,cust_name代表顾客名称
cust_name
andy
ben
tony
tom
an
lee
hex
【问题】
编写 SQL 语句,组合 Products 表中的产品名称(prod_name)和 Customers 表中的顾客名称(cust_name)并返回,然后按产品名称对结果进行升序排序。
【示例结果】
prod_name
an
andy
ben
flower
hex
lee
rice
ring
tom
tony
umbrella
【示例解析】
拼接cust_name和prod_name并根据结果升序排序

  • select prod_name
    from Products
    inner join
    select cust_name
    from Customers
    order by prod_name
  • select prod_name
    from Products
    left join
    select cust_name
    from Customers
    order by prod_name
  • select prod_name
    from Products
    union all
    select cust_name
    from Customers
  • select prod_name
    from Products
    union all
    select cust_name
    from Customers
    order by prod_name

这道题你会答吗?花几分钟告诉大家答案吧!