I am at a complete loss of how to do this in an ActiveRecord: Example select concat(c.last_name, '', '', c.first_name,) as name from customer c inner join basketball b on (c.id=b.cust_id) where b.start_date > ''8/1/2007'' union select concat(c.last_name, '', '', c.first_name,) as name from customer c inner join football f on (c.id=f.cust_id) where b.start_date > ''8/1/2007'' union select concat(c.last_name, '', '', c.first_name,) as name from customer c inner join soccer s on (c.id=s.cust_id) where b.start_date > ''8/1/2007'' order by name Any help would be greatly appreciated. Thanks. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
find_by_sql ;-) On 8/16/07, George Pasley <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I am at a complete loss of how to do this in an ActiveRecord: > > Example > > select concat(c.last_name, '', '', c.first_name,) as name > from customer c inner join basketball b on > (c.id=b.cust_id) > where b.start_date > ''8/1/2007'' > union > select concat(c.last_name, '', '', c.first_name,) as name > from customer c inner join football f on > (c.id=f.cust_id) > where b.start_date > ''8/1/2007'' > union > select concat(c.last_name, '', '', c.first_name,) as name > from customer c inner join soccer s on > (c.id=s.cust_id) > where b.start_date > ''8/1/2007'' > order by name > > Any help would be greatly appreciated. Thanks. > -- > Posted via http://www.ruby-forum.com/. > > > >-- Cheers! - Pratik http://m.onkey.org --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
So there is no way to use AR to do this? Or do I need to hack my own solution... Pratik Naik wrote:> find_by_sql ;-) > > On 8/16/07, George Pasley <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> select concat(c.last_name, '', '', c.first_name,) as name >> Any help would be greatly appreciated. Thanks. >> -- >> Posted via http://www.ruby-forum.com/. >> >> > >> > > > -- > Cheers! > - Pratik > http://m.onkey.org-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
To clarify, I know how to do this using find_by_sql. I figure I need to use ActiveRecord because I need to pass parameters to the query, such as the date field. I can''t find a way to pass a parameter using find_by_sql.> Pratik Naik wrote: >> find_by_sql ;-) >> >> On 8/16/07, George Pasley <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >>> select concat(c.last_name, '', '', c.first_name,) as name >>> Any help would be greatly appreciated. Thanks. >>> -- >>> Posted via http://www.ruby-forum.com/. >>> >>> > >>> >> >> >> -- >> Cheers! >> - Pratik >> http://m.onkey.org-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---