看板 PHP 關於我們 聯絡資訊
大大們請問一個問題我想要新增一筆資料 但想設個條件,假如欄位1與欄位2都相同的話,代表重複項 因此不可以新增此筆資料。 以下是我寫的SQL 但總是出錯,煩請各位大大指導一下。 INSERT INTO power (`Id`,`Account`,`Form`)VALUES('','root','123') WHERE not exists (SELECT * FROM power WHERE `Account` = 'root' AND `Form`='123') MySQL 傳回: #1064 - 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 not exists (SELECT * FROM power WHERE `Account` = 'root' AND `Form`='123'' at line 2 -- Aman ia vida 地下飛行 blog: http://luo74128.blogspot.com/2010/07/blog-post.html 我: http://www.wretch.cc/album/luo74128 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 202.134.88.79
tn801534:舊版mysql?不能子查詢? 查一下版本吧 07/30 16:35
arrack:INSERT INTO 不能直接接where 07/30 18:53
averywu:INSERT .... ON DUPLICATE KEY UPDATE 07/31 22:31
yukang:設 uniq index 不是比較好嘛?也不用每次都塞 08/01 08:16