|
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
What relationship am I missing in this query?
Hi, all...Rick Faircloth 05/21/08 11:59 A 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
|
Mailing Lists
|
Latest Fusion Authority Articles
|
||||||