Is there a way to make this query more efficient?
Perhaps using group by ?
I am trying to find photos where no photo has been designate as main.
WHERE property.property_id NOT
FROM property, property_photo
WHERE property.property_id = property_photo.property_id
AND property_photo_main = '1'
you can try this
FROM property p
LEFT JOIN property_photo pp ON p.property_id = pp.property_id
AND pp.property_photo_main = '1'
WHERE pp.property_id IS NULL