find_by

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

Model.all(:conditions => ["id = ? AND type = ?", id, type])

http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M002263

i have already did in this method i was looking for a function like that. Thanks.

you can do find_by_xxx_and_yyy_and_zzz (with as many conditions as you want)

Fred

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.

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 ActiveRecord::Base

Fred

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@googlegroups.com.

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.

Hello dear please check it this :

Abc.find(:all, :conditions => “id = 1” && “type = a”, :order => “created_on DESC”)

thanks : Surender Pal Pareek