In my notes table (MySQL database) I have id as the primary key. I want the column originalid to be the value of the primary key. Here is the query I run after creating a record which I thought would work.
UPDATE notes SET originalid = (SELECT MAX(id) FROM notes) where id = (SELECT MAX(id) FROM notes);
But I get the error
You can't specify target table 'notes' for update in FROM clause
Any advice or solutions on how I can work around this?
original_idwhere the primary keyidon every row. The question shows that Schwarz only wants this to occur on the last row. – RolandoMySQLDBA Sep 14 '15 at 16:35MAX()in his SQL statement. It just appeared that he was overcomplicating the query based on the wording of his question. – Nigel Tufnel Sep 14 '15 at 16:39