I have a table holding items with item_order column as non-nullable INT.
When I create a new item I need the highest item_order existing in the table, so I can increment it and insert new record. Below an abstract example of what I mean:
INSERT INTO item (name, item_order)
VALUES ('New Item', (SELECT MAX(item_order) FROM item AS item_order) + 1)
I assume this is crazy talk :) How do I achieve what I need?
UPDATE:
I found this useful: Increment a database field by 1
Can I then use SELECT MAX(item_order) + 1
as I showed above, as VALUES
argument?