0

Hi i am using codeigniter and in database my table name is posts have one column countriesId in which i have values like this1, 21, 13, 162, 172, 182, 155.

so in query i want to split the values 1, 21, 13... and match the query value.

for example if i use LIKE and i am asking about record of countryID "1" it will match 1, 21, 13 because there is "1" in values. how can i break the string within query and match the exact integer?

Thanks..

Ahmad Gulzar
  • 355
  • 2
  • 8
  • 23

2 Answers2

0

You can FIND_IN_SET() function.

Mudassir Hasan
  • 28,083
  • 20
  • 99
  • 133
0

So you want to use the FIND_IN_SET function. I don't know what your database schema looks like but your query will look something like this.

SELECT countries.*, posts.countriesId FROM posts, countries WHERE FIND_IN_SET(countries.countryID, posts.countriesId) AND posts.postId = '1'
Pattle
  • 5,983
  • 8
  • 33
  • 56