確定我已經找到你的解決方案我張貼
$condition = 1;// Condition will be provided by you for selection. Could be zero
$data = array(
'members.name',
'subordinates.points',
'subordinates.event'
);
$this->db->select($data);
$this->db->join('members','members.code = subordinates.member_code','left');
$this->db->join('boss','boss.event = subordinates.event','left');
$this->db->where('boss.condition_type',$condition);
$this->db->where('boss.event = subordinates.event');
$this->db->get('subordinates');
我也有在評選活動,讓你認識到事件的查詢將帶來的差異。請測試一下,看看它是否適合你。列名可能有一點區別。一個好的方法是像這樣使用表格之間的簡單易懂的關係。
Table1 : members
Columns : id , code , name
Table2 : boss
Columns : id , event , member_code , condition_type
Table3 : subordinates
Columns : id , boss_event , member_code , points
看你這個帖子這會回答你 http://stackoverflow.com/questions/10053670/how-to-inter-link-three-mysql-tables-using-codeigniter/10053734# 10053734 – 2012-04-07 11:31:35
感謝Raheel,您的回覆以及您在我另一篇文章中的回答。事情就是你在那篇文章中給我看的腳本..正確地加入這些表格,但不幸的是它並沒有幫助我實現我在這篇文章中提到的內容。你能幫我在這裏嗎? :) – 2012-04-07 12:10:14
請讓您的問題更清楚 – 2012-04-07 13:02:26