简体   繁体   中英

FIND_IN_SET for part of string in Mysql

I need to make a query to a table in my database. Until now I was using FIND_IN_SET because I have strings like this: "twitter,bycicle,car" .

Then, I could search by FIND_IN_SET("twitter", nameOfColumn)

But now, I need to search just part of each "set", for example: "twitter>10,bycicle,car"

It still works fine for bycicle and car but if I need to search for twitter, I cannot find it. What is the correct way to do this?

The following query would give you what you want, however use it with caution with respect to the data you have:

SELECT *
FROM table1
WHERE col1 RLIKE 'twitter'

Working Fiddle: http://sqlfiddle.com/#!2/66f538/1

Use LIKE operator:

SELECT *
FROM table1
WHERE nameOfColumn LIKE '%twitter%';

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