gpt4 book ai didi

php - 'userc.u_id' 中的未知列 'on clause'

转载 作者:行者123 更新时间:2023-11-29 20:22:42 25 4
gpt4 key购买 nike

我正在使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com