【发布时间】:2019-05-27 16:53:03
【问题描述】:
我必须合并两个表并将表中的值替换为第三列中的值。
表格看起来像这样 顺序
order date product_type quantity cost
1 1/1/19 tops 2 49.99
2 1/2/19 bottom 3 190
3 1/2/19 jewelry 1 30
product
order date product type product name
1 1/1/19 tops sophia tank
2 1/2/19 bottom boyfriend jeans
3 1/2/19 jewelry alex necklace
type
ascin_product ascin
tops 0081112
bottom 121412
jewelry 12412415
输出应该是这样的
order date quantity cost product name ascin
1 1/1/19 2 49.99 sophia tank 0001112
2 1/2/19 3 190 boyfriend jeans 121412
3 1/2/19 1 30 alex necklace 12412415
[在此处输入图片描述][2]
我可以轻松加入订单和产品,只是不知道如何加入基于 ascin 产品的第三张表,然后在整个表中用 ascin 替换产品类型
select order, date, product_type,product_name from product
inner join on order
product.product_type=order.product type
inner join on type
product.product_type=order.product type=type=ascin_product
我不知道如何用 ascin 替换表中的产品类型
【问题讨论】:
-
到目前为止你得到了什么结果?
-
我得到了 ascin 产品和其他列,但不是 ascin
-
试试
select order, date, product_type,product_name, ascin -
这是有道理的,但我想从决赛桌中删除 product_name。