Jump to content

Delete doesn't work (I want to delete multiple rows)


rain13
 Share

Recommended Posts

I ran into strange problem. SELECT works but DELETE doesn't I want to delete all rows WHERE (UserID = 2 AND UserGroupID = 3 AND UserStatus = 1) With select * :

SELECT * FROM usergroups WHERE (UserID = 2 AND UserGroupID = 3 AND UserStatus = 1) LIMIT 0,2;SELECT * FROM usergroups WHERE (UserID = 2 AND UserGroupID = 9 AND UserStatus = 1) LIMIT 0,1;

It works nicely But when I try delete *

DELETE * FROM usergroups WHERE (UserID = 2 AND UserGroupID = 3 AND UserStatus = 1) LIMIT 0,2;DELETE * FROM usergroups WHERE (UserID = 2 AND UserGroupID = 9 AND UserStatus = 1) LIMIT 0,1;

I get

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM usergroups WHERE (UserID = 2 AND UserGroupID = 3 AND UserStatus = 1) LIMI' at line 1

Or with delete with out *

DELETE FROM usergroups WHERE (UserID = 2 AND UserGroupID = 3 AND UserStatus = 1) LIMIT 0,2;DELETE FROM usergroups WHERE (UserID = 2 AND UserGroupID = 9 AND UserStatus = 1) LIMIT 0,1;

I get

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '2' at line 1

Edited by SoItBegins
Link to comment
Share on other sites

You should remove the limit clauses. It is used differently in a delete statement than in a select statement. In a delete statement limit sets the number of records you want to delete, so it uses only 1 parameter. That's why the error message says near '2'. That's the 2 in 'limit 0,2'. So remove the limit clauses all together.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...