سؤال

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