开发者

php mysql query issue

开发者 https://www.devze.com 2023-03-08 04:42 出处:网络
here\'s my table: and I want get the customers which have some values of for/category fields which is comma separated..

here's my table:

php mysql query issue

and I want get the customers which have some values of for/category fields which is comma separated..

I am trying something like this:

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

but its giving empty result.


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

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

The alternative, typing the column name once is:

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


Try:

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

精彩评论

暂无评论...
验证码 换一张
取 消