0
我正在使用代碼點火器實現連接查詢。我有兩個表Codeigniter根據兩個連接條件連接兩個表
1) Users -> Contains all users
2) Query -> Contains queries assigned to users. Each query has two users to attend that query.
在查詢表我有兩列
1) attendingMD -> First user attending that query
2) secondAttendingMD -> Second user that query.
我要顯示的查詢列表中有兩個用戶參加該查詢的姓名。我設法通過使用此代碼獲得第一個用戶的姓名。
$this->db->select("Query.*, Users.fullname as firstMD");
$this->db->join('Users', 'Users.id = Query.attendingMD');
$this->db->where('Query.isCompleted', 1);
$query = $this->db->get('Query');
return $query->result_array();
非常感謝,它的工作就像一個魅力。你真了不起。 –