我正致力于从不同的表中获取客户详细信息。我已经创建并测试了这个查询,它工作正常。问题是如何将用户(转换)为Active Query查询。谢谢。如何使用相关子查询进入Codeigniter中的活动记录查询
SELECT c.cust_id, `c`.`cust_contact_name`, `c`.`cust_active_flag`,
(select COUNT(`pm`.`cust_id`) from property_master as pm
Where pm.cust_id = c.cust_id) as prop_count,
(select a.addr_phoneno1 from address as a
WHERE a.cust_id = c.cust_id AND a.addr_type_flag IN ('C', 'CP')) as cust_phone,
(select count(ci.cust_id) from customer_inquiry as ci
WHERE ci.cust_id = c.cust_id) as inquiry_count,
(select max(inq_date) from customer_inquiry as ci
WHERE ci.cust_id = c.cust_id) as last_inq_date
FROM customer as c
GROUP BY c.cust_ID
@hekmat你可以在这个先生感谢 –