I have a table that has two different references to an address table. I would like to replace each reference id with the actual columns in a view. I envision something like what follows, but that does not work. I am using MySQL 5.5. What is the correct grammar?
CREATE VIEW Company AS
select id, Name AccountName, JoinDate, AccountStatus, CompanyName,
( select street1 MailStreet1, street2 MailStreet2, city MailCity, state MailState, county MailCounty, country MailCountry, postalcode MailPostalCode from Addresses where id = MailAddress limit 1 ) ,
( select street1 BillingStreet1, street2 BillingStreet2, city BillingsCity, state BillingState, county BillingCounty, country BillingCountry, postalcode BillingPostalCode from Addresses where id = BillingAddress limit 1 )
from Customer;
You can use LEFT JOIN instead of INNER JOIN if these address references may be empty.