I\'m trying to do a MERGE statement in Go:
query := \"MERGE staged ON (email=$1)\" +
\" WHEN NOT MATCHED THEN INSERT (email, secret, passwd, ts, newAcct)\" +
MERGE
is not supported by MySQL
, The equivalent for that is
INSERT ... ON DUPLICATE KEY UPDATE
Try this,
INSERT INTO tableName (email, secret, passwd, ts, newAcct)
VALUES ($1,$2,$3,$4,TRUE)
ON DUPLICATE KEY UPDATE newAcct=TRUE, existingUser=NULL, secret=$2, ts=$4
but be sure email
is set as Primary Key
or Unique
.