Hello,
I have this table called "testtab":
ID | value
----------
1 | 8
2 | 15
3 | 5
Field ID is INT autoincrement as usual for ID field, field value is common INT. I need to insert new record to it. The inserted value should be equal to the highest value +1. I tried to do something like this:
Mysql threw this error:Code:INSERT INTO testtab SET value=(select max(value) from testtab)+1
I searched internet and found that I cannot use the same table in a subqery of insert/delete/update query. So my question is: Is here some workaround for this? I know I could use two queries - one to find the maximum value and second to insert the value+1 into DB, but I would like to do it in a single query.Code:You can't specify target table for update in FROM clause
Thanks for help










Bookmarks