INSERT INTO tableX (ColumnPk,column1, column2)
VALUES((SELECT max(columnPk) from tableX)+1, 'Column1 value', 'Column2 Value')
I tried this but getting error 1093: You can't specify target table 'organizationmanagement' for update in FROM clause
INSERT INTO tableX (ColumnPk,column1, column2)
VALUES((SELECT max(columnPk) from tableX)+1, 'Column1 value', 'Column2 Value')
I tried this but getting error 1093: You can't specify target table 'organizationmanagement' for update in FROM clause
You don't use VALUES
when you're using the result of SELECT
:
INSERT INTO tableX (ColumnPk, column1, column2)
SELECT max(columnPk)+1, 'Column value', 'Column2 value';
Is there a reason you didn't configure columnPk
as an auto-increment column, so it would do this automatically?