我正在尝试根据这两个表中的ID收集2个表,表[2]的数据将进入表[0],这要归功于它们共有的id和第2个板的ditto 。这就是我已经做过的事情:
$sql1 = Db::getInstance()->executeS('
SELECT ra.id_customer, c.firstname AS Prénom, c.lastname AS Nom, COUNT(DISTINCT(rs.id_customer)) AS NbFilleuls, SUM(o.total_products_wt + o.total_shipping) AS CA
FROM ' . _DB_PREFIX_ . 'customer c
LEFT JOIN ' . _DB_PREFIX_ . 'rewards_account ra ON(c.id_customer = ra.id_customer)
LEFT JOIN ' . _DB_PREFIX_ . 'rewards_sponsorship rs ON(ra.id_customer = rs.id_sponsor)
LEFT JOIN ' . _DB_PREFIX_ . 'orders o ON(rs.id_customer = o.id_customer)
WHERE ra.remind_active = 1
GROUP BY rs.id_sponsor');
$sql2 = Db::getInstance()->executeS('
SELECT ra.id_customer, SUM(o.total_products_wt + o.total_shipping) AS CA_DATE
FROM ' . _DB_PREFIX_ . 'customer c
LEFT JOIN ' . _DB_PREFIX_ . 'rewards_account ra ON(c.id_customer = ra.id_customer)
LEFT JOIN ' . _DB_PREFIX_ . 'rewards_sponsorship rs ON(ra.id_customer = rs.id_sponsor)
LEFT JOIN ' . _DB_PREFIX_ . 'orders o ON(rs.id_customer = o.id_customer)
WHERE o.date_add >= \'2018-04-09 00:00:00\'
AND o.date_add <= \'2018-04-13 00:00:00\'
GROUP BY rs.id_customer');
$result = array_merge($sql1, $sql2);
感谢您的帮助。