下面是我的表,它是類似於另一個現有的表。但是執行查詢時出現一個錯誤。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