题目来源:
leetcode题目,网址:1795. 每个产品在不同商店的价格 - 力扣(LeetCode)
解题思路:
分别获取 store1 ,store2,sotre3 的内容,然后合并三表即可。
解题代码:
# Write your MySQL query statement below
select product_id,"store1" as store,store1 as price
from Products
where store1 is not null
union
select product_id,"store2" as store,store2 as price
from Products
where store2 is not null
union
select product_id,"store3" as store,store3 as price
from Products
where store3 is not null
总结:
无官方题解。