我有一个查询,它在phpmyadmin中生成结果,但在codeigniter中不生成结果。
$sql = "SELECT express_interests.*,
cl_to .User_Name AS ToClient,
cl_from.User_Name AS FromClient,
cl_from.Member_Id AS FromMid,
cl_to.Member_Id AS ToMid
FROM express_interests
INNER JOIN users AS cl_to ON cl_to.User_Id = express_interests.To_Id
INNER JOIN users AS cl_from ON cl_from.User_Id = express_interests.User_Id";
我想在codeignator中使用相同的查询。这就是我用过的
$this->db->select('express_interests.*,
cl_to .User_Name AS ToClient,
cl_from.User_Name AS FromClient,
cl_from.Member_Id AS FromMid,
cl_to.Member_Id AS ToMid
');
$this->db->from('express_interests');
$this->db->join('users AS cl_to', 'cl_to.User_Id = express_interests.To_Id');
$this->db->join('users AS cl_from', 'cl_from.User_Id = express_interests.User_Id');
当我用这个的时候它说
“字段列表”中的未知列“cl\u to.user\u name”
在codeigniter中使用上述查询的正确方法是什么。
2条答案
按热度按时间hjzp0vay1#
将此替换为
表别名和列名之间不需要的间距
t98cgbkg2#
代替
具有
或者可以直接在codeigniter中运行sql语句