Is a sub query necessary for this?

Hi All,

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.

SELECT property.property_id
FROM property
WHERE property.property_id NOT
IN (

	SELECT property.property_id
	FROM property, property_photo
	WHERE property.property_id = property_photo.property_id
	AND property_photo_main = '1'

you can try this

SELECT p.property_id
          , pp.property_id
   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