0
有我的代碼空值
select @k:=if(kode="k",nominal,0) as Kredit,@d:=if(kode="d",nominal,0) as
debet, @s:[email protected][email protected]@d as saldo from trx
我要顯示在基於表的結構降低的結果,但結果是空值
有我的代碼空值
select @k:=if(kode="k",nominal,0) as Kredit,@d:=if(kode="d",nominal,0) as
debet, @s:[email protected][email protected]@d as saldo from trx
我要顯示在基於表的結構降低的結果,但結果是空值
@s
需求是在MySQL中設置爲1 + NULL = NULL
;您可以留下參加選擇設置變量在執行語句之前,如果你不能保持如下一個MySQL會話:
SELECT
@k := IF(kode = "k", nominal, 0) AS Kredit,
@d := IF(kode = "d", nominal, 0) as debet,
@s:= @s + @k - @d AS saldo
FROM trx
LEFT JOIN (SELECT @s := 0) AS `setVar` ON 1=1
謝謝解決了兄弟:) –
*作爲一般規則,比SET語句等,你永遠不應該賦值給一個用戶變量並在相同的語句中讀取該值。http://dev.mysql.com/doc/refman/5.7/en/user-variables.html – 1000111