I would use LOCATE:
set @string = '/example1|example2/';
select * from YourTable
where locate(YourStringField,@String) = 0
Вопрос
Lets say I want to select all rows that does not contain a long list of words. Lets say this list is shortened for the sake of this example to only "example1" and "example2".
Im guessing using REGEXP would be the best option, instead of specifying
and field not like '%example1%' and field not like '%example2%'
but Im not sure how to go about it. Im guessing something like this?
WHERE !REGEXP(field, '/example1|example2/')
Решение
I would use LOCATE:
set @string = '/example1|example2/';
select * from YourTable
where locate(YourStringField,@String) = 0
Другие советы
MySQL support for regular expressions is very limited, but I think you could use this solution:
SELECT *
FROM yourtable
WHERE
field NOT RLIKE '[[:<:]]example1[[:>:]]|[[:<:]]example2[[:>:]]'
where [[:<:]]
and [[:>:]]
are word boundaries, and | is the OR operator