我真的不擅长sql。
这种情况是我想搜索两个表中的数据。
这是我的模特。
public function get_commission_week($username, $weekId){
$this->db->select('mc.clientId, mc.account,cb.weekId,cb.create_at');
$this->db->from('tb_member_client mc', 'tb_commission_bonus cb');
$this->db->where('mc.account', $username);
$this->db->where('cb.weekId', $weekId);
$this->db->join('tb_commission_bonus cb', 'cb.clientId = mc.clientId');
$query = $this->db->get();
return $query->result()->$row;
}
如何对具有本周用户名相关数据的数组进行SQL搜索?
答案 0 :(得分:0)
试试这个:
public function get_commission_week($username, $weekId){
$this->db->select('mc.clientId, mc.account,cb.weekId,cb.create_at');
$this->db->from('tb_member_client mc');
$this->db->where('mc.account', $username);
$this->db->where('cb.weekId', $weekId);
$this->db->join('tb_commission_bonus cb', 'cb.clientId = mc.clientId','left');
$query = $this->db->get();
return $query->result()->$row;
}