dimanche 25 janvier 2015

IF in WHERE clause

del=0 - not deleted, del=1 - sender and reciever deleted message, del=2 - sender deleted message, del=3 - receiver deleted message. My code is



SELECT
*
FROM
messages
WHERE
(`from` = :owner AND `to` = :partner) OR (`from` = :partner AND `to` = :owner) AND IF(`from` = :owner,`del`=3 OR `del`=0,`del`=2 OR `del`=0)
ORDER BY
id DESC


But it does not work. Help please.


Aucun commentaire:

Enregistrer un commentaire