I want to Select tblProperty.ID only when this query returns greater than 0
SELECT
COUNT(tblProperty.ID) AS count
FROM
tblTenant AS tblTenant
INNER JOIN tblRentalUnit
ON tblTenant.UnitID = tblRentalUnit.ID
INNER JOIN tblProperty
ON tblTenant.PropertyID = tblProperty.ID
AND tblRentalUnit.PropertyID = tblProperty.ID
WHERE tblProperty.ID = x
Where x is equal to the parent's tblProperty.ID that it is looking at. I do not know what 'x' is.
How can I do this?
Database Structure:
tblTenant:
ID
PropertyID <--foreign key to tblProperty
UnitID <--foreign key to tblRentalUnit
Other Data
tblProperty:
ID
Other Data
tblRentalUnit:
ID
PropertyID <--foreign key to tblProperty
Other Data
Explanation of the query:
The query is select only the properties that have rental units that have tenants living in them.