caner taşdemir caner taşdemir - 11 months ago 58
MySQL Question

mySQL - FIND_IN_SET() doesn't find the value

I m trying to get posts which includes a spesific tag.

The tag row content



SELECT * FROM shares WHERE FIND_IN_SET(tag, 'iphone') > 0 ORDER BY DATE DESC limit 10

What is the correct way to do it ?

Answer Source

Your tag is iphone|1468338028 and you look for iphone. That does not match.
Replace the | with , to separate the values.

SELECT * FROM shares 
WHERE FIND_IN_SET(replace(tag, '|', ','), 'iphone') > 0