How to delete multiple ids from database

Hello,

I would like to know how to delete multiple rows with diferent id`s or text using .txt or .csv from database.

Let say i have this id`s like here below but 100 or more.

2114396
2114382
2114377
2114373
2114356
2114353
2114348

Wat is the best way to do that.

Thanks in advance.

DELETE FROM da_table WHERE id IN (2114396, 2114382, 2114377, 2114373, 2114356, 2114353, 2114348)

(Though it does slightly depend on what database model is being used)

Thank You, is this the best way?

It’s one of two ways, the other way being

DELETE FROM da_table WHERE id=2114396 OR id=2114382 OR id=2114377 OR id=2114373 OR id=2114356 OR id=2114353 OR id=2114348

Neither way is better than the other, altough the first way I showed (DELETE ... WHERE IN ...) is obviously shorter (and easier to read IMHO)

Not sure what you mean by that?

The assumption is being made that it’s a SQL based model, but the second post from OP implies it.
The only other exception is if the number of ID’s being deleted is more than 50% of the rows in the table; then the shorter/more readable would be a NOT IN list.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.