hi, I have to retrieve data from table with two conditions using a actully the following query select * from abc where id=1 and type = ''a'' how will i do if: find_by_id(id) >>>>> how will i use for multiple conditions -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 15 March 2010 10:47, M I R <m.irfansb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> select * from abc where id=1 and type = ''a'' > > how will i do if: > > find_by_id(id) >>>>> how will i use for multiple conditionsModel.all(:conditions => ["id = ? AND type = ?", id, type]) http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M002263 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
i have already did in this method i was looking for a function like that. Thanks. On Mar 15, 3:56 pm, Michael Pavling <pavl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 15 March 2010 10:47, M I R <m.irfa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > select * from abc where id=1 and type = ''a'' > > > how will i do if: > > > find_by_id(id) >>>>> how will i use for multiple conditions > > Model.all(:conditions => ["id = ? AND type = ?", id, type]) > > http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M002263-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Mar 15, 10:47 am, M I R <m.irfa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hi, > I have to retrieve data from table with two conditions using a actully > the following query > > select * from abc where id=1 and type = ''a'' > > how will i do if: > > find_by_id(id) >>>>> how will i use for multiple conditionsyou can do find_by_xxx_and_yyy_and_zzz (with as many conditions as you want) Fred -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
find_by_xxx_and_yyy_and_zzz (with as many conditions as you want) how will i put the values against xxx, yyy and zzz, i am new to rails so please give me an explicit example. On Mar 15, 4:06 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Mar 15, 10:47 am, M I R <m.irfa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > hi, > > I have to retrieve data from table with two conditions using a actully > > the following query > > > select * from abc where id=1 and type = ''a'' > > > how will i do if: > > > find_by_id(id) >>>>> how will i use for multiple conditions > > you can do find_by_xxx_and_yyy_and_zzz (with as many conditions as you > want) > > Fred-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Mar 15, 11:20 am, M I R <m.irfa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> find_by_xxx_and_yyy_and_zzz (with as many conditions as you want) > how will i put the values against xxx, yyy and zzz, > i am new to rails so please give me an explicit example. >There are some examples on http://api.rubyonrails.org/classes/ActiveRecord/Base.html Fred> On Mar 15, 4:06 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > > > On Mar 15, 10:47 am, M I R <m.irfa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > hi, > > > I have to retrieve data from table with two conditions using a actully > > > the following query > > > > select * from abc where id=1 and type = ''a'' > > > > how will i do if: > > > > find_by_id(id) >>>>> how will i use for multiple conditions > > > you can do find_by_xxx_and_yyy_and_zzz (with as many conditions as you > > want) > > > Fred-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Mon, Mar 15, 2010 at 4:17 PM, M I R <m.irfansb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hi, > I have to retrieve data from table with two conditions using a actully > the following query > > select * from abc where id=1 and type = ''a'' > > how will i do if: > > find_by_id(id) >>>>> how will i use for multiple conditions > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >Hello dear please check it this :> Abc.find(:all, :conditions => "id = 1" && "type = a", :order => "created_on > DESC") >thanks : Surender Pal Pareek -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.