Queries w/ Joins & Concatenated Fields: find_by_sql vs find


I have the following query I want to use to create a html

SELECT contact.id,
concat(contact.lname, ", ", contact.fname) AS name FROM contacts contact INNER JOIN lu_contact_categories category 2. the find method can also accomplish this.

you can do this with find, yes. The :select parameter represents the field list to retrieve (defaults to *). Also, the :joins and :conditions parameters can be used to define a inner join. You could also use :include and save the :joins/:conditions part, but that will give you a LEFT OUTER.


javier ramirez

Thank you for your comments! - Brian