2016-05-13 4 views
-5
SELECT `users`.`first_name`, `user_profile`.`user_id`, 
`user_profile`.`image`, `messages`.* FROM `messages` LEFT JOIN `user_profile` ON 
`user_profile`.`user_id` = `messages`.`from_id` LEFT JOIN `users`ON `users`.`id` 
= `messages`.`from_id` WHERE (messages.delete_from != '9' AND messages.delete_to 
!='9’) AND (`messages`.`members` = '4,9' OR `messages`.`members` = '9,4') 
ORDER BY `date` ASC 
+1

のための使用$this->db->group_start();$this->db->group_end();はhttps://www.codeigniter.com/userguide3/database/query_builder.html#selecting-data –

+4

アクティブを読んで、怠けて停止し、これを読んでマニュアルを記録してそれを入手してください – Ghost

+0

$ this-> db-> from($ this-> table); $ this-> db-> select( 'users.first_name、user_profile.user_id、user_profile.image、messages。*'); $ this-> db-> join( 'user_profile'、 'user_profile.user_id = messages.from_id'、 'left'); $ this-> db-> join( 'users'、 'users.id = messages.from_id'、 'left'); $ this-> db-> where($ id1); $ this-> db-> where($ id2); $ this-> db->ここで( 'messages.members'、$ con1); $ this-> db-> or_where( 'messages.members'、$ con2);私はこれを使用しましたが、動作していません – Anju

答えて

0
$this->db->from($this->table); 
$this->db->select('users.first_name,user_profile.user_id,user_profile.image,messages.*'); 
$this->db->join('user_profile', 'user_profile.user_id = messages.from_id','left'); 
$this->db->join('users', 'users.id = messages.from_id','left'); 
$this->db->where($id1); 
$this->db->where($id2); 
$this->db->group_start(); 
$this->db->where('messages.members',$con1); 
$this->db->or_where('messages.members',$con2); 
$this->db->group_end(); 
$this->db->order_by('date','asc'); 

括弧

関連する問題