我在codeigniter中加入兩個表時遇到此錯誤。錯誤號:1064
Error Number: 1064
You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use
near '.`id = a`.`assignee_key where a`.`assigned_to="office" and
user`.`id="53"`' at line 1
select a`.* from address as `a LEFT JOIN user ON user`.`id = a`.`assignee_key where a`.`assigned_to="office" and user`.`id="53"
$this->db->select('select a.* from address as a LEFT JOIN user ON user.id = a.assignee_key where a.assigned_to="office" and user.id="'.$user_id.'"');
$query = $this->db->get();
return $query->row();
我猜想使用'AS'沒有什麼錯誤。 –
似乎你缺少左'周圍表名.. \'表名\'\'列名\' – diEcho