Reputation: 2670
How to get next highest number from mysql rows, given one row id.
Eg.
Categories | sort_order
Animal | 400
Cars | 500
>
Vans | 550
Now I want to add a category under Cars, over Vans which I have to check what is next highest number after 500.
So when I add 400 should return 500, when 500 should retrun 550.
Upvotes: 0
Views: 128
Reputation: 12485
Should be as simple as the following:
SELECT MIN(sort_order) FROM mytable
WHERE sort_order > 500;
Upvotes: 2
Reputation: 44766
select min(sort_order) + 1 from tablename where sort_order >= 500
Untested, but should work.
Upvotes: 0