Selecting records of a column which has two values separated by comma

Hi all,

In a table there is column called village which is text datatype. Now my question is few records will have 1,2 under village column some records will have only 2 or 1. when I do query I should be able to select those records which has 1,2 . If I want to select all the records of village(2). How can I do this in rails query.

Tried with Like and IN (?) in query but did not work

City.find(:all, :conditions => [“village LIKE ?”,2])
City.find(:all, :conditions => [“village IN (?)”,2])
as it is text datatype and if I pass 1,2 I am able to get the records but while passing single value like 1 or 2

Kindly suggest how to get it

Thanks in advance

Don't store the data like that, it will cause you endless problems and
you will look back in the future and ask why you did it that way.
Possibly it should be in separate fields, or even in a separate table.
It depends what the data represents. If you provide the context then
it may be possible to suggest the best alternative.

Colin

thanks. I fixed it. Sure I will consider your suggestion.