SELECT g.date,g.description,g.amount AS cash,0 AS cheque FROM generalledger AS g WHERE g.type="cash" AND (g.date=@gdate OR @gdate IS NULL)
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=@gdate OR @gdate IS NULL)
I've this query I want to set the @gdate parameter value from php function, I'm using codeigniter. Is there any other way to do this?