gmail
account.
Using IF
statement:SELECT *
FROM `students`
WHERE IF(LENGTH(mail), mail, mail2) LIKE '%gmail.com%'
ORDER BY points
Using OR
logical operator:SELECT *
FROM `students`
WHERE
(`mail` LIKE '%gmail.com%' AND LENGTH(mail))
OR
(mail2 LIKE '%gmail.com%')
ORDER BY points
Using CASE
SELECT *
FROM `students`
WHERE
(CASE
WHEN LENGTH(mail) THEN mail
ELSE mail2
END) LIKE '%gmail.com%'
ORDER BY points