SELECT g.date,g.description,g.amount AS cash,0 AS cheque FROM generalledger AS g WHERE g.type="cash" AND g.date=?
UNION ALL
SELECT gg.date,gg.description,0 AS cash, gg.amount AS cheque FROM generalledger AS gg WHERE gg.type="cheque" AND gg.date=?

I've this query I want to check if g.date's & gg.date's parameter value is null then return all the records other wise only return records according to the parameter value.

有帮助吗?

解决方案

Try

AND (g.date=? or ? is null)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top