我對結果表明 查詢現在,我需要和M1,M2如何總結M1和M2在此查詢
查詢:
select metraj, fee, tedad, fee_tedad,
metraj * fee AS m1,
tedad * fee_tedad AS m2
from content
where id = 54
我對結果表明 查詢現在,我需要和M1,M2如何總結M1和M2在此查詢
查詢:
select metraj, fee, tedad, fee_tedad,
metraj * fee AS m1,
tedad * fee_tedad AS m2
from content
where id = 54
做這樣
select metraj, fee, tedad, fee_tedad,
metraj * fee AS m1,
tedad * fee_tedad AS m2,
metraj * fee+tedad * fee_tedad as sum
from content
where id = 54
你試過這個嗎? –
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
以下應該工作:
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
嘗試添加'metraj *費+ tedad * fee_tedad'。你不能在SELECT中使用'SELECT'子句的別名。 –
任何你爲什麼標記jquery的原因? –
當你說sum時,你的意思是每行或者所有行的總數? – apokryfos