简体   繁体   中英

using concat in where like query

First off, I'm a beginner at this so please be patient with me. I've tried searching the forums here, and elsewhere and from what I can see I'm doing it right.. but I get an error. to "Check syntax to use near 'LIKE CONCAT(games.tag, ' Special%') AT LINE X". So clearly I'm doing it wrong.. But everything I have found says I've done it right. Someone please help I'm getting frustrated.

SELECT
games.tag,
ribbons.name,
members.username,
members.joined
FROM
member_ribbons
INNER JOIN ribbons
 ON member_ribbons.ribbon_id = ribbons.id
INNER JOIN games
 ON ribbons.game_id = games.id
INNER JOIN members
 ON member_ribbons.member_id = members.id
WHERE games.id = members.primary_game AND discharged='000-00-00' AND ribbons.name = LIKE CONCAT(games.tag, ' Special %');

An Example ribbons.name will contain "BF4 Special Consideration"

I need to be able to find that specific one.. but the only thing that changes is the first word which is contained in games.tag. The rest of the Query works. Just need to figure out how to get it to do this and I'm good. However Searching google everywhere and here has not shown any examples of how to do this.. Is it even possible? Clearly I'm doing this wrong.

you have extra =

change this

  AND ribbons.name = LIKE CONCAT
                   ^----//--no need this

to

  AND ribbons.name LIKE CONCAT

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM