[MySql] How to make UPDATE to create a row, instead of doing nothing if the row doesnt exist. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [MySql] How to make UPDATE to create a row, instead of doing nothing if the row doesnt exist. (
/showthread.php?tid=467185)
[MySql] How to make UPDATE to create a row, instead of doing nothing if the row doesnt exist. -
Unri - 01.10.2013
As the title says, how can i make an update command to create the row, if the row with the specified ID does not exist?
Re: [MySql] How to make UPDATE to create a row, instead of doing nothing if the row doesnt exist. -
overflow - 01.10.2013
You have to check whether the row exists or not. If it doesn't create a new row (
INSERT INTO) otherwise just update it (
UPDATE). The update statement itself can't create new rows.
Re: [MySql] How to make UPDATE to create a row, instead of doing nothing if the row doesnt exist. -
Unri - 01.10.2013
Theres no other way?
Re: [MySql] How to make UPDATE to create a row, instead of doing nothing if the row doesnt exist. -
Mauzen - 01.10.2013
Search for "INSERT … ON DUPLICATE KEY UPDATE"
This one either creates a new row with the given data, or updates the existing one. Exactly what youre looking for I guess.