The idea is that after looping over a submission form, all rows not just updated by the form are deleted from the database.
Is there an elegant MySQL declaration for something like that?
The idea is that after looping over a submission form, all rows not just updated by the form are deleted from the database.
Is there an elegant MySQL declaration for something like that?
No. Store the PKs and use NOT IN after to delete.
Deleting before hand is dangerous; what if a user closes the browser? Aid storing primary keys is an option. The simplest ended up being this:
1) Set all matching row dates to something like Jan 1 1970. 2) Submit form, including current time in updated rows. 3) Delete all rows with old date.
Works very well.
you could have a timestamp column in the table. all rows that are updated would have the current timestamp. and then you can run a delete query selecting all rows that would have their timestamps less than the approximate time when you updated the table. not a full-proof solution though.
another would be to set some columns value while updating, and later deleting the rows whose column value did not get updated
How about a reversed condition?
Update tbl set this = that where col = 'something'; Delete from tbl where col != 'something';