Reputation: 1
I have a MySQL table where staff_id is the Primary Key and id is an AUTO_INCREMENT column. When I insert data in order, everything works fine:
id staff_id
1 2022
2 2023
3 2024
4 2025
But when I insert an older staff_id (e.g., 2020), the display order changes, but the id value remains out of sequence:
id staff_id
5 2020
1 2022
2 2023
3 2024
4 2025
Issue:
I want the id values to match the staff_id order, so that when I insert 2020, it should get id = 1 and shift other rows down like this:
id staff_id
1 2020
2 2022
3 2023
4 2024
5 2025
Upvotes: -3
Views: 39