Need to filter email addresses

You can do this type:

SELECT * FROM messages WHERE email NOT LIKE '%@ya.ru' AND email NOT LIKE '%@google.com' AND email NOT LIKE '%@yahoo.com' 

The question is - is it possible to implement this with one REGEXP (NOT REGEXP) and, if so, is it worth it?

    1 answer 1

    try this:

     SELECT * FROM messages WHERE email NOT REGEXP '@(ya\.ru|google\.com|yahoo\.com)$'; 

    SQL Fiddle Test

    About "стоит ли?" - it is necessary to compare the performance on your data

    • Thank you very much, but why screen "@"? Plus I would add “$” to the end of the expression after the parentheses - RostD
    • one
      @RostD, yes about @ - I was reinsured (I wasn’t sure that there was such a special RegEx character - I’ve checked it now - it seems there isn’t any). In general, I corrected in response ... - MaxU Nov.