So I join two tables in a query, let’s use below as an example:
SELECT property.address, property.city, property.state, property.zip, unit.name
FROM property, unit
WHERE unit.propertyID = property.id
This table can return a list of all properties that have a matching unit in the unit table.
My problem is, if I have properties that DO NOT have units, I still want those to show up, with “N/A” or “NULL” or something in place of the unit name…
As of now, it just completely excludes those properties that don’t have at least 1 matching unit.
Any ideas?
Simplest way to update your query to working order:
Better way to write it, using aliases:
To populate a value when there is no unit: