|
First. let me say that MySql does allow for the COALESCE function
and and Nelson's SQL should work. I would say however, the 3rd null
parameter is not needed, if the first field is null it will use the
second field whether or not it has a null value. SELECT S.* , coalesce(A1.addresstype, A2.addresstype) AS AddressType , coalesce(A1.addresstype, A2.addresstype) AS AddressLine1 , coalesce(A1.addresstype, A2.addresstype) AS City , coalesce(A1.addresstype, A2.addresstype) AS State FROM Students S LEFT JOIN Addresses A1 ON S.id = A1.empid and A1.addressType = 'temporary forward' LEFT JOIN Addresses A2 ON S.id = A2.empid and A2.addressType = 'permanent forward' Second for performance, I agree with the general consensus that having the DB do all the work is usually the most efficient. There is one caveat for this though... datatype conversions. Have coldfusion convert all datatypes to what is defined in the table definition. If for some strange reason, zipcodes are stored as an integer field, use WHERE zip_code = 7003, not WHERE zip_code = '07003'. The reverse is true too... if you have a field that stores numbers as a string use WHERE string_field = '34'; do not use WHERE string_field = 34; I used to work on an oracle system where people were ignorant of how a field was defined and oracle would slow to a crawl due to implicit type conversions. Remember, Coldfusion only needs to convert the datatype once, the database may do it for each individual row. On 04/09/2012 10:59 AM, Nelson Winters wrote: If you're using SQL Server, something like this should work:------------------------------------------------------------- To unsubscribe from this list, manage your profile @ http://www.acfug.org?fa=login.edituserform For more info, see http://www.acfug.org/mailinglists Archive @ http://www.mail-archive.com/discussion%40acfug.org/ List hosted by http://www.fusionlink.com ------------------------------------------------------------- |
- Re: [ACFUG Discuss] Unconscionable Adobe Behavior John Mason
- Re: [ACFUG Discuss] Unconscionable Adobe Behavior Peyton Todd
- Re: [ACFUG Discuss] Unconscionable Adobe Behavior shawn gorrell
- Re: [ACFUG Discuss] Unconscionable Adobe Behavi... Peyton Todd
- Re: [ACFUG Discuss] Unconscionable Adobe Behavi... Cameron Childress
- Re: [ACFUG Discuss] Unconscionable Adobe Behavi... William Evans
- Re: [ACFUG Discuss] Unconscionable Adobe Behavi... William Evans
- [ACFUG Discuss] Tricky SQL help? Tepfer, Seth
- Re: [ACFUG Discuss] Tricky SQL help? Nelson Winters
- Re: [ACFUG Discuss] Tricky SQL help? Frank Moorman
- RE: [ACFUG Discuss] Tricky SQL help? Charlie Arehart
- RE: [ACFUG Discuss] Tricky SQL help? Tepfer, Seth
- RE: [ACFUG Discuss] Tricky SQL help? Charlie Arehart
- RE: [ACFUG Discuss] Tricky SQL help? Tepfer, Seth
- Re: [ACFUG Discuss] Tricky SQL help? Dawn Hoagland
- Re: [ACFUG Discuss] Tricky SQL help? Cameron Childress
- Re: [ACFUG Discuss] Tricky SQL help? Ed Szwedo
- Re: [ACFUG Discuss] Tricky SQL help? Nelson Winters
- Re: [ACFUG Discuss] Tricky SQL help? rl . xenos
- Re: [ACFUG Discuss] Tricky SQL help? Dawn Hoagland
