• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 370
  • Last Modified:

How can you delete multiple rows with a single XSQL statement?

I am needing to delete 500 discrete records from a table which all have unique ids but this is taking a LONG time.  I'm wanting to optimize the process by doing it with a single statement.  But what I'm trying says "zero rows deleted"

DELETE FROM `mytable` WHERE (`id` = '123456') OR (`id`  = '456789');

Any leads?  What's the most efficient way to delete a lot of data from a table?
1 Solution
create a temp table with all the ids you want to delete with an index on that field

then delete like this

delete a.* from table1 a inner join temp table b on a.id = b.id


Try this out

DELETE FROM `mytable` WHERE  ID IN ('123456', '456789'')

kirin0Author Commented:
Perfect... thanks.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now