티스토리 뷰

UNION 에는 두 가지 방법 이 있습니다.

$data['values']=$this->db->query(
'select ID,Name_of_Movie as Name_of_Moviee from moviestable       
 UNION  
 select ID,New_Name from moviestable')->get()->result_array();
 

UNION의 두 번째 방법

$this->db->select("ID,Name_of_Movie as Name_of_Moviee");
$this->db->from("moviestable");
$query1 = $this->db->get_compiled_select(); // It resets the query just like a get()

$this->db->select("ID,New_Name");
$this->db->distinct();
$this->db->from("moviestable");
$query2 = $this->db->get_compiled_select(); 

$data['values'] = $this->db->query($query1." UNION ".$query2)->result();

쿼리에 대해 하나를 구현하고 있습니다.



출처
https://stackoverflow.com/questions/39917146
댓글
공지사항
Total
Today
Yesterday
«   2025/09   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30