簡體   English   中英

連接同一個表和列兩次

[英]Join same table and columns twice

我做了2張桌子。 一個分配給工作的用戶(稱為雇主):

桌子商店_雇主

...第二個用戶:

表用戶

我想在shops_employers吸引列se_u_id獲取用戶的用戶名和姓,並再次姓名訴諸列shops_employers se_so_add_u_id。 這是我寫的代碼:

$this->db->from('shops_employers as se');
$this->db->where('se_s_id', $shopID);
$this->db->where('se_accepted', 1);
$this->db->where('se_active', 1);
$this->db->join('users as u', 'se.se_u_id = u.u_id');
return $this->db->get()->result();

但我不知道接下來要做什么。

嘗試:

$this->db->from('shops_employers se');
$this->db->where('se.se_s_id', $shopID);
$this->db->where('se.se_accepted', 1);
$this->db->where('se.se_active', 1);
$this->db->join('users u', 'se.se_u_id = u.u_id', 'left');
return $this->db->get()->result();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM