Problem with php mysql

here is my table:

enter image description here

and I want to get clients that have field values for/categoryseparated by commas.

I am trying something like this:

SELECT * FROM `customers` WHERE `for` LIKE ('%AMC PHD & WWS%' OR '%Rostfrei%' OR '%Thermopac%')

but it gives an empty result.

+3
source share
2 answers

RedFilter SQL is correct, but you should also know that "for" is a MySQL reserved word. You should avoid using it as the column name or wrap it in backticks when using it:

SELECT * 
FROM customers 
WHERE `for` LIKE '%AMC PHD & WWS%'
    OR `for` LIKE '%Rostfrei%'
    OR `for` LIKE '%Thermopac%';

An alternative by typing the column name once is:

SELECT * FROM customers WHERE `for` REGEXP 'AMC PHD \& WWS|Rostfrei|Thermopac';
+4
source

Try:

SELECT * 
FROM customers 
WHERE for LIKE '%AMC PHD & WWS%'
    or for LIKE '%Rostfrei%'
    or for LIKE '%Thermopac%'
+3
source

All Articles