i'm trying accomplish join of multiple tables in mysql. have managed write following query:
select concat(c.first_name, ' ', c.last_name) name, c.title, c.department, concat(c2.first_name, ' ', c2.last_name) reports_to, c.phone_work, c.phone_mobile, e.email_address email_addresses e, email_addr_bean_rel eb, contacts c left join contacts c2 on c.reports_to_id = c2.id c.id = eb.bean_id , e.id = eb.email_address_id;
this producing table data require, problem not include full list of contacts. when count of contacts there 130 above query results reduced 86.
after investigating have discovered down contacts not have email address being ignored , don't want not sure how stop them being ignored if have null entry.
the email_addresses
table contains email address email address
contact
lookup has done in email_addr_bean_rel
using contacts
id
first
select concat_ws(' ',c.first_name,c.last_name) name , c.title , c.department , concat_ws(' ',c2.first_name,c2.last_name) reports_to , c.phone_work , c.phone_mobile , e.email_address contacts c left join email_addr_bean_rel eb on eb.bean_id = c.id left join email_addresses e on e.id = eb.email_address_id left join contacts c2 on c2.id = c.reports_to_id
Comments
Post a Comment