下面是我的表,它是类似于另一个现有的表。但是执行查询时出现一个错误。MySQL错误号:1064当插入到数据库
//
public function addFirstChild() {
$this->db->query("INSERT INTO " . $this->db->table("genealogy") . "
WHERE parent_id = '" . (int)$this->getSponsorID() . "'
SET first_child = '" . (int)$this->getId()."',
genealogy_id = '" . (int)$this->getId() ."'");
}
执行时,我得到了以下错误:
SQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE parent_id = '1' SET first_child = '2', ' at line 2 Error No: 1064 SQL: INSERT INTO ci_genealogy WHERE parent_id = '1' SET first_child = '2', genealogy_id = '2' in C:\wamp64\www\s1nb2\core\database\amysqli.php on line 108
还有,我能想到的来拉这个功能没有其他办法,我在网上搜索,并用同样的错误读取多个职位,但仍然无解。请帮忙。我花了4个多小时试图做到这一点。
@JayBlanchard权在指甲上出现。 –
如果答案解决了您的问题,请考虑接受答案。以下是http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work然后返回到此处,并使用勾号/复选标记执行相同操作,直至变为绿色。这告知社区,找到了解决方案。否则,其他人可能会认为这个问题仍然存在,并且可能需要发布(更多)答案。您将获得积分,其他人将被鼓励帮助您。 *欢迎使用Stack!* –
或者如果您需要插入,则可以在'values(...)'子句或'set'子句中提供所有值,不要使用'where'。 – Shadow