1
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

Talha Ahmed Khan
  • 15,043
  • 10
  • 42
  • 49
Ankit Tater
  • 599
  • 3
  • 9
  • 26
  • possible duplicate of [In MySQL, can I copy one row to insert into the same table?](http://stackoverflow.com/questions/4039748/in-mysql-can-i-copy-one-row-to-insert-into-the-same-table) – Denis Rendler Feb 11 '14 at 11:38

1 Answers1

1

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?

Barmar
  • 741,623
  • 53
  • 500
  • 612