If inside Where mysql
- by Barno
Can I do an if inside Where?
or something that allows me to do the checks only if the field is not null (path=null)
SELECT
IF(path IS NOT NULL, concat("/uploads/attachments/",path, "/thumbnails/" , nome), "/uploads/attachments/default/thumbnails/avatar.png") as avatar_mittente
FROM prof_foto
WHERE profilo_id = 15
-- only if path != "/uploads/attachments/default/thumbnails/avatar.png"
AND foto_eliminata = 0 AND foto_profilo = 1