我想问是否可以在连接后指定 where 子句,以便将数据与用户输入匹配。比如说我有以下代码:
$this->db->select('user.*,role.*')
$this->db->from('user');
$this->db->where('user.username', $username);
$this->db->where('user.password', $password);
$this->db->join('role','role.id = user.role_id')
$result = $this->db->get();
我想从表'role'中查询匹配的数据:
$this->db->select('user.*,role.*')
$this->db->from('user');
$this->db->where('user.username', $username);
$this->db->where('user.password', $password);
$this->db->join('role','role.id = user.role_id')
$this->db->where('role.speaker', $speaker); //want to know if this is correct
$result = $this->db->get();
这可能吗?我可以在 JOIN 之后比较结果(使用 WHERE)吗?这会产生与 WHERE 子句匹配的结果吗?
谢谢!