i have this table:
item_id item_name item_status visibility "item_number"
6 foo6 3 1 4
5 foo5 2 1 3
4 foo4 1 0 x
3 foo3 3 1 2
2 foo2 2 0 x
1 foo1 1 1 1
the items are "in mercy" of the visibility
field. if i want to set visibility to 0, like for example items_id
's 2 and 4, i would like the "item_number
" (not a real column) to adjust accordingly.
if i were to select items that have a item_status
of 2, it would return items of status 2 but with the "adjusted" item has the item_number
of 3.
is this possible in PHP+MySQL?
normally you would have the item_id
as the id for the item. however, the issue is that MySQL auto-increment would still continue even if you deleted an item (in this case, it's the visibility
column). so if i recently added item 6 then deleted items 2 and 4, the next item_id
would have a 7 but there are only 4 items in the database. for these "visible" items, i want to have item numbers 1, 2, 3 and 4 instead of ids 1, 3, 5, and 6.
also, if i were to get items with an item_status
of 2, normally you would get an item with an item_id
of 5. but that item is only 3rd in the database (due to previously deleted items) so i want to return 3.