Let's say I have a query: I wish to run 'CC=z' condition only if AA=x. Is there a way to do it in one query?
I would say you're after: $sql = "SELECT * FROM TABLE WHERE (AA = x AND CC = z) OR BB = y ORDER BY DD"; instead.