14 Dec
2014
14 Dec
'14
12:06 a.m.
Hi, Roberto! On Dec 13, Roberto Spadim wrote:
Hi guys i'm with a doubt about the "standard" (sql standand?) error reporting , about INSERT SELECT...
should this insert select return duplicate key? INSERT INTO errorsX (id) SELECT MAX(id)+1 FROM errorsX;
considering: ---- CREATE TABLE errorsX( id INT NOT NULL DEFAULT 0, PRIMARY KEY (id) ) ; ----
Depends on how many rows the table errorsX has. If it has only one row, than this INSERT ... SELECT will insert a one row with a different id. No error. If it has more than one row, this INSERT ... SELECT will try to insert more than one row, all with the same id value - there will be a duplicate key error. Regards, Sergei