作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Codeigniter,并且尝试检索角色 ID 为 3 的所有用户及其所有已保存的自定义字段。由于某种原因,我收到数据库错误
“‘on 子句’中存在未知列‘userc.u_id’”
$this->db->join('(SELECT GROUP_CONCAT(data) AS custom_data, id AS dataid, u_id
FROM ea_user_cfields userc
GROUP BY id) AS tt', 'userc.u_id = ea.id','left');
$this->db->join('(SELECT GROUP_CONCAT(name) AS custom_name, id AS customid
FROM ea_customfields AS cf
GROUP BY id) AS te', 'userc.c_id = cf.id','left');
$this->db->where('id_roles', $customers_role_id);
return $this->db->get('ea_users ea')->result_array();
实际查询:
SELECT * FROM (`ea_users` ea)
LEFT JOIN (SELECT GROUP_CONCAT(data) AS custom_data, id AS dataid, u_id FROM
ea_user_cfields userc GROUP BY id) AS tt ON `userc`.`u_id` =
`ea`.`id`
LEFT JOIN (SELECT GROUP_CONCAT(name) AS
custom_name, id AS customid FROM ea_customfields AS cf GROUP BY id) AS
te ON `userc`.`c_id` = `cf`.`id` WHERE `id_roles` = '3'
最佳答案
使用下面的代码可能会对您有所帮助。
SELECT * FROM (`ea_users` ea)
LEFT JOIN (SELECT GROUP_CONCAT(data) AS custom_data, id AS dataid, u_id FROM
ea_user_cfields userc GROUP BY id) AS tt ON tt.`u_id` =
`ea`.`id`
LEFT JOIN (SELECT GROUP_CONCAT(name) AS
custom_name, id AS customid FROM ea_customfields AS cf GROUP BY id) AS
te ON tt.`c_id` = `cf`.`id` WHERE `id_roles` = '3'
关于php - 'userc.u_id' 中的未知列 'on clause',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39450909/
我在数据库中有一个具有以下结构的表 id u_id number game score status 1 2 123 COC 214 active 2 2 535
SELECT `attendence`.`u_id` , DATE_FORMAT(date,'%d-%m-%Y') as `date`, `attendence`.
我正在使用 Codeigniter,并且尝试检索角色 ID 为 3 的所有用户及其所有已保存的自定义字段。由于某种原因,我收到数据库错误 “‘on 子句’中存在未知列‘userc.u_id’”
我是一名优秀的程序员,十分优秀!