[請益] MYSQL 不重複新增資料
大大們請問一個問題我想要新增一筆資料
但想設個條件,假如欄位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
推
07/30 16:35, , 1F
07/30 16:35, 1F
→
07/30 18:53, , 2F
07/30 18:53, 2F
→
07/30 18:54, , 3F
07/30 18:54, 3F
→
07/31 22:31, , 4F
07/31 22:31, 4F
推
08/01 08:16, , 5F
08/01 08:16, 5F
PHP 近期熱門文章
PTT數位生活區 即時熱門文章
151
156