I cant use auto increment in phpmyadmin for this but I would like to see if its possible and find a way to get the max(displayorder) +1 every time there's a row insert. Could someone sh开发者_JAVA技巧ow me how this is done if it's possible? I am using mysql.
Why can't use auto_increment?
This should work.
INSERT INTO yourTable (displayOrder, someColumn, someColumn)
SELECT sq.displayOrder, someValueToBeInserted, someValueToBeInserted
FROM (
SELECT MAX(displayOrder) + 1 AS displaOrder
FROM yourTable
) AS sq
but be aware that it is unreliable.
精彩评论