SELECT
contacts.id AS CONTACTID,
accounts.id AS ACCOUNTID,
contacts.first_name,
contacts.last_name,
contacts.phone_work,
contacts.phone_fax,
contacts.department,
contacts.title,
contacts.description,
contacts.salutation,
email_addresses.email_address,
contacts.deleted
FROM
contacts
INNER JOIN accounts_contacts
ON contacts.id = accounts_contacts.contact_id
JOIN accounts
ON accounts.id = accounts_contacts.account_id
INNER JOIN email_addr_bean_rel EABR
ON contacts.id = EABR.bean_id
INNER JOIN email_addresses EM
ON EABR.email_address_id = EM.id
WHERE
contacts.first_name = 'shamraiz'
Ligesom de andre spørgsmål, jeg har hjulpet dig med...
Angiv én tabel ad gangen, INNER JOIN (eller LEFT JOIN) til den næste tabel "ON", uanset hvilke kriterier de to tabeller relaterer til... Derefter INNER JOIN (eller LEFT JOIN) til den næste tabel i relationshierarkiet.
Hvis du har flere kontaktoplysninger for den samme person, såsom forskellige konti og/eller e-mails, VIL du få flere poster.