kohkindachi Posted May 17, 2009 Share Posted May 17, 2009 Hey guys I need help in deleting rows in mysql db. There're only 2 column in this table namely 'index' and 'link' The column 'index' is numbered with ascending numbers from 1 onwards. What i wan is to delete the wh0le rows with index 50000 or less, which mean as long as it falls within 1 to 50,000 i want to delete it. any suggested query for this? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/158442-solved-help-with-sql-mulitple-row-delete/ Share on other sites More sharing options...
ldougherty Posted May 17, 2009 Share Posted May 17, 2009 SURE.. DELETE from table WHERE index < 50000 Quote Link to comment https://forums.phpfreaks.com/topic/158442-solved-help-with-sql-mulitple-row-delete/#findComment-835591 Share on other sites More sharing options...
kohkindachi Posted May 17, 2009 Author Share Posted May 17, 2009 It gives me an error ??? SQL query: DELETE FROM downloads WHERE INDEX <50000 MySQL said: Documentation #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 'index < 50000' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/158442-solved-help-with-sql-mulitple-row-delete/#findComment-835592 Share on other sites More sharing options...
ldougherty Posted May 17, 2009 Share Posted May 17, 2009 What is the field type for index? Quote Link to comment https://forums.phpfreaks.com/topic/158442-solved-help-with-sql-mulitple-row-delete/#findComment-835594 Share on other sites More sharing options...
kohkindachi Posted May 17, 2009 Author Share Posted May 17, 2009 Field | Type | Null | Extra index int(5) No auto_increment Quote Link to comment https://forums.phpfreaks.com/topic/158442-solved-help-with-sql-mulitple-row-delete/#findComment-835596 Share on other sites More sharing options...
ldougherty Posted May 17, 2009 Share Posted May 17, 2009 Not sure, tried the same on my junk database and it worked perfectly fine. I'm assuming that downloads is your table name right? If that is indeed correct then the only thing that comes to my mind is the word INDEX maybe being a unique name. Try adjusting syntax just for giggles. DELETE FROM downloads WHERE index < 50000 Quote Link to comment https://forums.phpfreaks.com/topic/158442-solved-help-with-sql-mulitple-row-delete/#findComment-835597 Share on other sites More sharing options...
kohkindachi Posted May 17, 2009 Author Share Posted May 17, 2009 Got it to work DELETE FROM downloads WHERE `index` < 50000 Quote Link to comment https://forums.phpfreaks.com/topic/158442-solved-help-with-sql-mulitple-row-delete/#findComment-835599 Share on other sites More sharing options...
fenway Posted May 19, 2009 Share Posted May 19, 2009 Yeah, don't use reserved keywords for column names. Quote Link to comment https://forums.phpfreaks.com/topic/158442-solved-help-with-sql-mulitple-row-delete/#findComment-837328 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.