Ruby on Rails Wednesday, October 28, 2015

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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7f4c9d50-1d6b-4f37-8aa3-2af03cf82478%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment