Correlated Sub Query in Select Problem
I have a query that I would like the company_id from the outer Select for use in the subquery, but no matter what I try I get 'Unknow column 'c.company_id' in 'on clause'. I have read the MySQL documentation and I think that I am doing it the way they specify, but I might not have interpreted it correctly. Can you see why this doesn't work or how it can be done?
c.company_id as 'Company Id'
phone_numbers as p
p.company_id = c.company_id) as 'Phone Number'
, a.address as 'Address'
companies as c
JOIN companies2addresses as c2a
ON c2a.company_id = c.company_id
JOIN addresses as a
ON a.address_id = c2a.address_id;