2014-01-08 27 views
0

這次我需要一個大的幫助。我需要編寫一個mysql查詢來連接兩個表以及查詢應該有一些case語句。我不是mysql查詢方面的專家,所以我甚至不會考慮寫這個。所以我做了一個圖表,如果有人可以請給我一些幫助。我需要用case語句寫mysql查詢

非常感謝。 enter image description here

我試過使用這個查詢。但是這甚至不能達到這個要求。

$this->db->select('user.emp_servicing_dep,user.emp_department,user.emp_name,user.emp_applied_date,user.emp_applied_time,user.hod_apprvd_time,user.hr_apprvd_time,user.emp_servicing_brnch' 
       . ',user.emp_pending_on,user.emp_status,Management.Br_no,Management.Br_name,Management.Contact_no,Management.user_name,Management.Hd_working_day,Management.Department'); 
     $this->db->order_by("emp_timestamp", "ASC"); 
     $this->db->limit(10); 
     $this->db->from('user'); 
     $this->db->join('Management', 'user.emp_pending_on = Management.Department', 'left'); 

enter image description here

enter image description here

+0

當然,堆棧溢出社區可以幫助你嘗試過。請分享您創建的查詢以及您面臨的問題。 –

+0

@AzizShaikh - 我提出了這個問題,現在我已經試過了我的問題。但是那個查詢從未做過我需要的事情。 :( 謝謝 – Yasitha

+0

請同時添加您的表格結構,樣本數據和預期結果。 –

回答