18 Oct
2014
18 Oct
'14
7:30 p.m.
Luigi Rosa lists@luigirosa.com wrote:
Sven Hartge wrote on 18/10/2014 18:07:
This SQL query looks correct to me. It INSERTs a new row for a username if one does not already exist but UPDATEs it if there is already such a row.
My fault: I didn't know this SQL syntax.
It is incredibly usefull. Otherwise you would have to do a SELECT first to decide if you want to INSERT or UPDATE as a second query and this creates a race condition if another process is able to do its INSERT after you decided there is no existing key because at the time if your first SELECT there was in fact none.
Grüße, Sven.
-- Sigmentation fault. Core dumped.