开发者

MYSQL subqueries using LIKE and IN

开发者 https://www.devze.com 2023-01-28 21:01 出处:网络
I\'m trying to put together a MYSQL query designed for an AJAX\\PHP CMS, which goes a little like this:

I'm trying to put together a MYSQL query designed for an AJAX\PHP CMS, which goes a little like this:

SELECT table.info 
FROM table 
WHERE table.variable LI开发者_如何学运维KE '%refinedby%' IN 
(SELECT other valid subquery to select data from)

However, I keep tripping syntax errors near LIKE '%refinedby'IN (

If I use = rather than LIKE there's no problem, as the following:

SELECT table.info 
FROM table 
WHERE table.variable = 'refinedby' IN 
(SELECT other valid subquery to select data from)

Does anyone have any ideas where I can't preceed a subquery with a LIKE selector?

Thanks in advance!


You can't use in like that you have to specify what is going to BE in

SELECT table.info 
FROM table 
WHERE table.variable LIKE '%refinedby%' 
and table.variable IN (SELECT other valid subquery to select data from)
0

精彩评论

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