I'm currently developing a REST API that connects to a MySQL database and does a bunch of queries.
In one of those queries I happen to have to delete a bunch of rows from a table and each of those rows have a unique identifier.
And basically I have two approaches to do so: (that I know).
- Build a bunch of
DELETE FROM table WHERE id=value;
statements and execute them sequentially. - Build only a
DELETE FROM
statement but with a massiveOR
chain.
I don't have a ton of experience handling databases and any suggestion or advice would be greatly appreciated.
EDIT:
I just noticed that I also have something similar happening with a UPDATE FROM
statement where I set a lot of records to the same given value, so any advice on that too would be really nice.
AUTO_INCREMENT
option on the MySQL column. EDIT: I also just realised that I have something similar with a UPDATE statement that sets a bunch of records to the same value.