Hello all,
I do have this case where I need to store some domain names and the type of operation and operation date, to later be displayed.
I do have a “natural” primary key (if we may say so?) on this case, that is the domain name.
The domain names will be a varchar. No issues.
Operation date will be catch by timestamp. No issues here as well. (I suppose).
So, instead of doing two methods, one for insert and another for update, I was thinking if I can do just one. If no record is present, insert, if not, update.
I end up on INSERT ON DUPLICATE KEY UPDATE.
Question:
INSERT INTO a.atualizaDominio
(a.nomeDominio,a.tipoAtualizacao)
VALUES (?,?) ON DUPLICATE KEY UPDATE
a.tipoAtualizacao=VALUES(a.tipoAtualizacao);
note: The ? are placeholders from PDO that’s why I have them there.
I’m getting this error:
INSERT,UPDATE command denied to user…
but I do have the privileges, so I believe it should be something to do with the query sintax?
Update: if I remove the alias I can run the command. But I’ve seen many of you using alias… and I believe it’s a best practice… ? ![]()
Would you not use an autoincrement ID column in this case, since the domain names serves as natural keys?
Thanks in advance,
Márcio