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

lesen diese https://www.codeigniter.com/userguide3/database/query_builder.html#selecting-data –

+4

faul stoppen, lesen Sie die aktive Handbuch aufzeichnen und damit fortfahren – 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 ('Benutzer', 'users.id = messages.from_id', 'left'); $ this-> db-> where ($ id1); $ this-> db-> where ($ id2); $ this-> db-> wo ('messages.members', $ con1); $ this-> db-> or_where ('messages.members', $ con2); Ich habe das benutzt, aber es funktioniert nicht – Anju

Antwort

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'); 

Verwendung $this->db->group_start(); und $this->db->group_end(); für Klammern