Hi all, Say, I have two tables (requirements & projreqs)and want to execute the following query. SELECT * FROM requirements WHERE(id = (SELECT req_id FROM projreqs WHERE proj_id = ?)); Being a newbie in Ruby, I know only to extract data from one table. Eg: Requirement.find(:all, :select, :condition) or Requirement.find_by_sql(query). But, how to combine two tables? Please help me out... Appreciate your help. Thanks, Tony Puthenveettil
on 2009-02-16 12:15
on 2009-11-07 07:34
Tony Puthenveettil wrote: > Hi all, > > Say, I have two tables (requirements & projreqs)and want to execute the > following query. > SELECT * FROM requirements WHERE(id = (SELECT req_id FROM projreqs WHERE > proj_id = ?)); > > Being a newbie in Ruby, I know only to extract data from one table. > Eg: Requirement.find(:all, :select, :condition) or > Requirement.find_by_sql(query). > > But, how to combine two tables? Please help me out... > > Appreciate your help. > > Thanks, > Tony Puthenveettil Hi, Extract data from two table or more table it's required that there is some relation exist between them. As per your need you use join or include for that. For more information go through this url http://api.rubyonrails.org/classes/ActiveRecord/As... Thanks, Priyanka Pathak
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.