Mysql filter and display entrys that doesn't contain specific words

Viewed 31

I would like to filter text data in a mysql table and would like to display only entrys that doesn't contain specific words like:

.de, .com, .cn

I tried as example SELECT * FROM TABLE WHERE EXAMPLE NOT LIKE '%.com%' and NOT LIKE '%.de%';

But this give me the error that i got a error in my mysql syntax.

3 Answers

wrong syntax

SELECT * FROM table WHERE column_name NOT LIKE '%.de%' 
AND column_name NOT LIKE '%.com%' 
AND column_name NOT LIKE '%.cn%';

If .com is the end of a word, you have to replace your LIKE with %.com

Ex : SELECT * FROM table WHERE column_name NOT LIKE '%.com';

Check how SQL LIKE operator works

This returns an error cause your syntax is incorrect Try,

SELECT * FROM TABLE WHERE EXAMPLE NOT LIKE '%.com%' AND '%.de%';
select * from table
where example
not like '%.com%' and 
example not like '%.de%'
Related