LoginSignup
0
0

More than 5 years have passed since last update.

SugarCRM5.2で取引先担当者と取引先、メールアドレスをJOIN

Last updated at Posted at 2012-11-08
SELECT C.*, A.*, email.`email_address` FROM `contacts` AS C LEFT JOIN `accounts_contacts` AS L
ON C.`id`=L.`contact_id` AND L.`deleted`=0
LEFT JOIN `accounts` AS A
ON L.`account_id`=A.id AND A.`deleted`=0
LEFT JOIN `email_addr_bean_rel` AS EL
ON C.id=EL.`bean_id` AND `bean_module`='Contacts' AND `primary_address`=1 AND EL.`deleted`=0
LEFT JOIN `email_addresses` AS email
ON EL.`email_address_id`=email.`id` AND email.`deleted`=0
where C.deleted=0

メールアドレスはメインアドレスのみのJOINです

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0