rain13 Posted April 21, 2012 Share Posted April 21, 2012 (edited) 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 April 21, 2012 by SoItBegins Link to comment Share on other sites More sharing options...
CCZ Posted April 21, 2012 Share Posted April 21, 2012 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 More sharing options...
rain13 Posted April 21, 2012 Author Share Posted April 21, 2012 I figured that brackets also caused problems. I need Limit but I figured it doesn't like limit 0,2 so i have to use limit 2 instead. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now