• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 372
  • 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?
0
kirin0
Asked:
kirin0
1 Solution
 
sandipshahCommented:
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

Ss

0
 
thomsonalexCommented:
Try this out

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

0
 
kirin0Author Commented:
Perfect... thanks.
0
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

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

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