Reputation: 340
I write this query but now i want to ignore all emails which have this string abv
after @
(both with upper or lower letters). Hope someone will help.
SELECT user_data.alternative_mail
FROM user_data
JOIN users_map
ON users_map.user_id = user_data.user_id
WHERE users_map.service_id = 1
AND users_map.service_user_id = 0
AND user_data.alternative_mail NOT LIKE '%@abv.bg'
AND user_data.alternative_mail IS NOT NULL
AND user_data.alternative_mail <> '';
Upvotes: 1
Views: 52
Reputation: 918
Try this:
SELECT user_data.alternative_mail
FROM user_data
JOIN users_map
ON users_map.user_id = user_data.user_id
WHERE users_map.service_id = 1
AND users_map.service_user_id = 0
AND user_data.alternative_mail NOT ILIKE '%@%abv%'
AND user_data.alternative_mail IS NOT NULL
AND user_data.alternative_mail <> '';
Upvotes: 0
Reputation: 2685
use ILIKE
instead of LIKE
(PostgreSQL Documentation) to make the match case-insensitive according to the active locale.
BTW: LIKE
does not use regular expressions
Upvotes: 1