I have this simple (actually I'm simplifying the real case) SQL command :
SELECT Username, Message
FROM Mail
WHERE DeleteBySender = '0'
LIMIT 1
but for some reason, I have special condition, that is :
IF Mail.Username = 'johndoe' then the WHERE clause is not DeleteBySender = '0' anymore, but DeleteByReceiver = '0'.
in short, how to make dynamic WHERE clause based on Mail.Username result?
can it be done with single SQL command? because if not, in my real case, it will cause PHP scripting more complex.
**UPDATE : what I really expect, in plain English : if Mail.Username NOT johndoe, SQL command will be like this :
SELECT Username, Message
FROM Mail
WHERE DeleteBySender = '0'
LIMIT 1
but if Mail.Username IS johndoe, SQL command will be like this :
SELECT Username, Message
FROM Mail
WHERE DeleteByReceiver = '0'
LIMIT 1