Is there a way to 'mark' a single row in a table and automatically unmark others?
0
votes
1
answer
444
views
Is there a way to flag one row in a database table (MariaDB/MySQL mostly, but I just want to know), so that there is only one row in a table that has that flag? If I set that flag (for eg. 'active') for any other row, then the row which currently has the 'active' flag is automatically unset. The idea is to not have to manually unset the older 'active' row when there's going to be a new one. I just insert/update a row with 'active'=1 and it's automatically the only one.
To clarify my intent, I'm not looking for a method of doing this manually - I'm trying to find out if there is a built-in feature in a database system, since this is a pretty common use case. Hence, the post in DBA, instead of SO. I don't even know what tags to use for this question.
Asked by aalaap
(101 rep)
Oct 20, 2016, 08:44 AM
Last activity: Dec 28, 2020, 09:06 AM
Last activity: Dec 28, 2020, 09:06 AM