Biribu
Biribu

Reputation: 3823

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?

Upvotes: 1

Views: 663

Answers (2)

Saharsh Shah
Saharsh Shah

Reputation: 29051

Use LIKE operator:

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

Upvotes: 0

Aziz Shaikh
Aziz Shaikh

Reputation: 16524

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

Upvotes: 1

Related Questions