select ID,Name_of_Movie as Name_of_Moviee
from moviestable
UNION
select ID,New_Name
from moviestable
I need this query in codeigniter..
select ID,Name_of_Movie as Name_of_Moviee
from moviestable
UNION
select ID,New_Name
from moviestable
I need this query in codeigniter..
there are two way for UNION first in below
$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();
Second way to UNION in
$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();
You are implement any one for your query