codeigniter按编号连接表而不是另一个表

时间:2014-04-30 18:40:27

标签: codeigniter join

当我尝试在codeigniter中进行此连接时

$this->db->join('ticketsale','ticketsale.id = 1');

我收到此错误:未知列' 1'在' on条款'

"SELECT * FROM (`users`) JOIN `ticketsale ` ON `ticketsale `.`id` = `1` JOIN `ticketsale_.."

如何让codeigniter不要把``大约1?

1 个答案:

答案 0 :(得分:0)

因为在join语句中,您必须使用列名来匹配它们并加入其他查询。如果您想这样做,您应该添加Where语句。 例如:

"SELECT * FROM (`users`) JOIN `ticketsale ` ON `ticketsale `.`id` = `hereyourtable`.`hereis the column` JOIN `ticketsale_..  WHERE `ticketsale `.`id`=1"

<强>更新: 此外,在活动记录中;

 $this->db->join("ticketsale","ticketsale.id=users.column")->where("ticketsale.id"=>"1");
this query will return same as native sql query