Deleting multiple rows in mysql (solved)

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Deleting multiple rows in mysql (solved)

Post by Luke »

what would be the syntax for deleting more than one row... would you have to just do multiple queries like this...

Code: Select all

DELETE FROM table WHERE id = 3;
DELETE FROM table WHERE id = 6;
DELETE FROM table WHERE id = 19;
DELETE FROM table WHERE id = 36;
Or is there some other way that would be better?
Last edited by Luke on Thu Nov 10, 2005 1:49 pm, edited 1 time in total.
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Code: Select all

DELETE FROM table WHERE id = 3 or id = 6 or id = 19 or id = 36
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

Code: Select all

DELETE FROM table WHERE id IN (3, 6, 19, 36)
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

Thanks
Post Reply