House of Fusion
Home of the ColdFusion Community

Search cf-talk

December 02, 2008

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
   1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31       

Search over 2,500 ColdFusion resources here  >>>      
Home /  Groups /  ColdFusion Talk (CF-Talk)

What relationship am I missing in this query?

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Hi, all...
Rick Faircloth
05/21/08 11:59 A
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Faircloth
05/21/2008 11:59 AM

Hi, all... I'm trying to return each property from the properties table, along with the *first* photo in the property_photos table for each property with this query: select p.property_id,        (select pp.photo_filename from property_photos pp,                properties p where pp.photo_mls_number =                substring_index(p.mls_number, '_', 1) limit 1)             as prop_photo_filename   from properties p, property_photos pp where substring_index(p.mls_number, '_', 1) = pp.photo_mls_number However, the query only return the first photo it finds and attaches it to every property instead of different photos for each property. I tried it without the "limit 1" qualification, but then every photo for every property is returned.  (Which is actually closer to the result I'm after...but I only want the first photo for each property) I just can't see the relationship qualification I'm missing? Suggestions, anyone? Thanks, Rick


<< Previous Thread Today's Threads Next Thread >>

Mailing Lists