I have the following query to pull properties. Properties have multiple units. I have no idea how to pull properties with at least 1 unit though. Units are connected to the properties by having the same “team”. The “team” is a varchar(ex. “jkdgsl”). Any suggestions?
SELECT DISTINCT Properties.id, Properties.title, Properties.team
FROM Properties
INNER JOIN Units ON Units.team = Properties.team
AND Units.rates != '0'
AND Properties.deleted = '0000-00-00 00:00:00'
AND Properties.zip_code
IN (
'77808', '77845'
)
AND Properties.public = '1'
ORDER BY FIELD( Properties.zip_code, '77808', '77845' )
LIMIT 0 , 30
I think you are already doing that (i.e. select properties that have at least one unit) by the nature of an inner join.