Question

How can I deactivate a row instead of deleting it, using flag values in MySQL?

No correct solution

OTHER TIPS

Add an active column to the table, and then do:

UPDATE YourTable
SET active = 0
WHERE id = :id

to deactivate the row. You'll then need to update all other queries so they do:

WHERE active = 1

There's no built-in mechanism that does this automatically.

You can create a column in your table as type CHARACTER(1), and use something like 'A' for active and 'D' for deactivated.

There isn't a "flag value" for mysql, people refer to it as a flag, as they created the flag within their own tables for use as such.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top