插入如果表中不存在记录,则在sql中不存在

问题描述 投票:0回答:1

好吧,我只想插入数据,如果它不存在于表中,如果它存在则不需要做任何事情

insert into colleges (Id, Name, CreatedOn) values("20", "ASIET", "2017-12-14 
06:44:32") where not exists (select id from colleges where name = "ASIET")

我收到了错误

Error Code: 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 id from colleges where name = "ASIET")' at 
line 1

并提前感谢您的帮助

mysql database mysql-workbench not-exists
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.