title: get notification from single table and join with multiple tables and result as single array
body: <p>i have a table like <a href="https://i.stack.imgur.com/HVA20.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HVA20.png" alt="enter image description here"></a></p>
  
  <p>and select all notifications from this table and join with below mentioned tables</p>
  
  <ol>
  <li><p>tbl_notice
  <a href="https://i.stack.imgur.com/9XLHs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9XLHs.png" alt="enter image description here"></a></p></li>
  <li><p>tbl_task</p></li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/6Tmjn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6Tmjn.png" alt="enter image description here"></a></p>
  
  <ol start="3">
  <li>tbl_assignment</li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/pot9s.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pot9s.png" alt="enter image description here"></a></p>
  
  <p>and i am trying to fetch datas from tables like</p>
  
  <pre><code>$sql = "select * from(
      (
      SELECT a.refer_id as id ,a.refer_tbl,b.task_name as name FROM tbl_notification as a
      LEFT JOIN tbl_task as b ON (a.refer_id= b.task_id )ORDER BY a.created_date desc
      ) UNION
      (
      SELECT c.refer_id as id ,c.refer_tbl, d.notice_title as name FROM tbl_notification as c
      LEFT JOIN tbl_notice as d ON (c.refer_id = d.notice_id)ORDER BY c.created_date desc
      ) UNION
      ( 
      SELECT e.refer_id as id,e.refer_tbl, f.title as name FROM tbl_notification as e
      LEFT JOIN tbl_assignment as f ON (e.refer_id = f.assignment_id) ORDER BY e.created_date desc
      ))";
     $query= $this-&gt;db-&gt;query($sql)-&gt;get();
  </code></pre>
  
  <p>the result shows the data from first table where  join (in case tbl_task) other tbl_notice and tbl_assignment details are null result demo like this
  <a href="https://i.stack.imgur.com/p9yjt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p9yjt.png" alt="enter image description here"></a></p>
  
  <p>Please help me to correct this.....</p>