Hi guys,
I have a problem with a MySQL query. I have two tables, shown below:
Table 1: PREMISES
prem_id
address
size
price
Table 2: TENANTS
ten_id
name
type
description
prem_id
I am trying to do a query that will find any premises that are NOT occupied by a tenant.
I was using this code:
Code:
select p1.address, p1.size, p1.price FROM premises AS p1,
tenants AS p2 WHERE p1.prem_id != p2.prem_id
BUT this displays all the premises that are not the same as the prem_id in the tenants table and does this for each tenant creating duplicated results.
Can anyone help me fix this query?
Thanks in advance.