Question

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.

Was it helpful?

Solution

Try

AND (g.date=? or ? is null)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top