Please help someone. There was a question select from few tables mysql. A get an answer, read the documentation about LEFT JOIN http://www.mysql.ru/docs/man/LEFT_JOIN_optimisation.html (russian language). So I have a working query:
select con.connection_id, com.company_name, ctx.contact_name
from connections as con
left join companies as com
on con.company_id = com.company_id
left join contacts as ctx
on con.contact_id = ctx.contact_id
WHERE com.name=LIKE ('%qwer%')
Thats work good. I have new table called addresses with two fields(id and street). In table companies there is a field with address_id. Make a new query:
select con.connection_id, com.company_name, ctx.contact_name
from addresses as add, connections as con
left join companies as com
on con.company_id = com.company_id
left join contacts as ctx
on con.contact_id = ctx.contact_id
where add.id=com.Legal_address
AND com.name=LIKE ('%qwer%')
It says:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'add, Connections as con LEFT JOIN Companies as com on con.company_id = com.id LE' at line 1
What I did wrong?