Tasos
February 28, 2015, 2:57pm
1
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.
rpkamp
March 1, 2015, 11:45am
2
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)
Tasos
March 1, 2015, 2:13pm
4
Thank You, is this the best way?
rpkamp
March 1, 2015, 4:22pm
5
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.
system
Closed
June 5, 2015, 11:34pm
7
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.