Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 如何使用where和加入codeigniter_Mysql_Codeigniter_Activerecord_Codeigniter 2_Codeigniter 3 - Fatal编程技术网

Mysql 如何使用where和加入codeigniter

Mysql 如何使用where和加入codeigniter,mysql,codeigniter,activerecord,codeigniter-2,codeigniter-3,Mysql,Codeigniter,Activerecord,Codeigniter 2,Codeigniter 3,我想加入2个表“最终用户”和“组” $this->db->select('*'); $this->db->from('enduser'); $this->db->where('groupid', $id); $this->db->join('group', 'group.groupid = enduser.groupid'); $query = $this->db->get(); 我使用了此代码,但它给了我一个错误: where子句中

我想加入2个表“最终用户”和“组”

$this->db->select('*');
$this->db->from('enduser');
$this->db->where('groupid', $id);
$this->db->join('group', 'group.groupid = enduser.groupid');
$query = $this->db->get();
我使用了此代码,但它给了我一个错误:

where子句中的“groupid”列不明确


请提供帮助。

错误消息的原因是:它无法识别where条件中指向的表

在中更改
groupid

$this->db->where('groupid',$id)

$this->db->where('enduser.groupid',$id)


$this->db->where('group.groupid',$id)

错误消息的原因是:它无法识别where条件中指向的表

在中更改
groupid

$this->db->where('groupid',$id)

$this->db->where('enduser.groupid',$id)

$this->db->where('group.groupid',$id)

尝试以下操作:

$this->db->select('*');
$this->db->from('enduser');
$this->db->where('enduser.groupid', $id);
$this->db->join('group', 'group.groupid = enduser.groupid');
$query = $this->db->get();
问题是,在联接之后,此查询中有两个名为groupid的列,因此必须向读取器指定要比较的列。

尝试以下操作:

$this->db->select('*');
$this->db->from('enduser');
$this->db->where('enduser.groupid', $id);
$this->db->join('group', 'group.groupid = enduser.groupid');
$query = $this->db->get();
$this->db->select('*');
$this->db->from('enduser');
$this->db->where('tablename.groupid', $id);
$this->db->join('group', 'group.groupid = enduser.groupid');
$query = $this->db->get();

问题是,在联接之后,此查询中有两列名为groupid,因此必须向读取器指定要比较的列。

错误消息是什么?@SankarV Column'groupid'在where子句中不明确错误消息是什么?@SankarV Column'groupid'在where子句中不明确
$this->db->select('*');
$this->db->from('enduser');
$this->db->where('tablename.groupid', $id);
$this->db->join('group', 'group.groupid = enduser.groupid');
$query = $this->db->get();