Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否有用于将数据插入 id = 表 id 的行的 SQL 命令,如果不存在则插入新行?
类似的东西:('INSERT INTO USERS IF EXISTS WHERE userID=ID')
你可以像这样写一些简单的东西:
IF (SELECT COUNT(t.ID) FROM t WHERE t.ID=@id)=1 UPDATE ELSE INSERT
我这样理解你的问题
INSERT INTO table1(value1, value2) SELECT value1, value2 FROM table2where table2.userID = Id