如何在此查询中求和m1和m2

时间:2017-07-15 06:06:33

标签: mysql sql

我有一个查询结果显示 现在,我需要总和m1,m2

查询是:

select metraj, fee, tedad, fee_tedad,
       metraj * fee AS m1,
       tedad * fee_tedad AS m2 
from content 
where id = 54 

3 个答案:

答案 0 :(得分:0)

这样做

echo

答案 1 :(得分:0)

select metraj, fee, tedad, fee_tedad, metraj * fee AS m1, tedad * fee_tedad AS m2, mtraj * fee + tedad * fee_tedad as m1_plus_m2 from content where id = 54

答案 2 :(得分:0)

以下内容应该有效:

select metraj, fee, tedad, fee_tedad, (metraj * fee) + (tedad * fee_tedad) AS someVariable, from content where id = 54 

如果您同时需要m1和m2,请使用以下内容:

select metraj, fee, tedad, fee_tedad, metraj * fee AS m1, tedad *fee_tedad AS m2, (metraj * fee) + (tedad * fee_tedad) AS someVariable  from content  where id = 54