id | Product | PrdouctOption| ServiceId
1 | 1 | 1 | 12
2 | 2 | 1 | 12
3 | 1 | 1 | 13
4 | 2 | 1 | 13
5 | 1 | 2 | 14
6 | 1 | 1 | 15
如何更新在我的表中的所有记录插入产品的新行= 2和productOption = 1,如果它不存在,它对于ServiceId。 (在这种情况下,对于serviceId 14和15)更新表中插入新行,如果不存在
我似乎无法获得逻辑权限。
到目前为止,这是我..
UPDATE dbo.MyTable
SET Product = 2, ProductOption = 1
//Can't figure out the logic for if it doesn't exist for a serviceid
你想要执行'UPDATE'或'INSERT'或者两者都可以? –
我不清楚你的问题是什么。 –
你正在使用哪些DBMS?不管是mysql还是sql-server,它们都不是一回事。 –