MySQL使每N个Cloumn成为新的一行

MySQL使每N个Cloumn成为新的一行,mysql,sql,Mysql,Sql,这就是我要做的。我想看看,基于一定的价格和成本,我的利润是多少。下面是一个例子: SELECT price, cost, profit, price-5 "price1", cost, price-5-cost "profit1" FROM table WHERE product = blue_pants; 这会像这样输出数据: price cost profit price1 cost profit1 price cost profit price1 cost profit1

这就是我要做的。我想看看,基于一定的价格和成本,我的利润是多少。下面是一个例子:

SELECT price, cost, profit, 
price-5 "price1", cost, price-5-cost "profit1"  
FROM table
WHERE product = blue_pants; 
这会像这样输出数据:

price cost profit price1 cost profit1  
price  cost profit
price1 cost profit1 
我希望它是这样的:

price cost profit price1 cost profit1  
price  cost profit
price1 cost profit1 
这就是我想要的数据显示方式。这有意义吗?有没有办法做到这一点。对不起,我是个SQL noob

Select price, cost, profit
From table
Where product = 'blue_pants'
Union All
Select price-5, cost, price-5-cost
From table
Where product = 'blue_pants'

这显然会重复行。为了知道哪些行应该出现在第一个查询中,哪些行应该出现在第二个查询中,我们需要知道条件(例如,
Where price-5>0
)。

UNION ALL是我所需要的。谢谢