我正致力於從不同的表中獲取客戶詳細信息。我已經創建並測試了這個查詢,它工作正常。問題是如何將用戶(轉換)爲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你可以在這個先生感謝 –