开发者

C# MySql if record exists update else insert?

开发者 https://www.devze.com 2023-02-15 14:38 出处:网络
lets say i have a column uniqueID that had \'1\' in it.What I want to do is only update called phonenumber 开发者_Python百科total.If it doesn\'t exist then insert. Is \'REPLACE into table\' what I am

lets say i have a column uniqueID that had '1' in it. What I want to do is only update called phonenumber 开发者_Python百科total. If it doesn't exist then insert. Is 'REPLACE into table' what I am looking for?


This is called an 'upsert' (UPdate/inSERT).

Examples at How to write flexible INSERT and UPDATE statements in MySQL


There is an SQL standard for this called "MERGE". Some recent version of Oracle and MSSQL2008+ support this. Not sure about MySQL

0

精彩评论

暂无评论...
验证码 换一张
取 消