The following mysql query…
SELECT a.*, b.*,
(
SELECT COUNT( * )
FROM lp_units c
WHERE c.property_id = a.property_id
) AS unitcount
FROM lp_property a,
lp_property_confidential b
WHERE a.property_id = b.property_id
AND c.unitcount<= a.no_of_units
AND a.account_id = '1'
returns an error…
Unknown column 'c.unitcount' in 'where clause'
I think my query would be understandable. solve it to run….
Thanks in advance…
Don’t use
c.unitcount. Justunitcount.unitcountis not a column ofcbut rather of the temporary table generated by the subquery.However, this query is probably better written as a join anyway.
Try this query