You have quotes around your table name:
mysql_query("DELETE FROM 'tblname' WHERE @i IN (1000,ROW_COUNT()) ORDER BY points DESC");
Replace them with backticks as such:
mysql_query("DELETE FROM `tblname` WHERE @i IN (1000,ROW_COUNT()) ORDER BY points DESC");
Edit: (deleting records)
Try:
mysql_query("DELETE TOP (1000) FROM `tblname` ORDER BY points DESC");
You can also try:
DELETE FROM tablename ORDER BY points DESC LIMIT 1000 *
Assuming this is a column named id
:
mysql_query("DELETE FROM tablename WHERE id > 1000");
That would leave the first 1,000 rows and remove every other entry.
A few more examples:
DELETE FROM `table` WHERE `id` < 1000
DELETE FROM `table` WHERE `id` LIMIT 0, 1000
DELETE FROM `table` WHERE ID BETWEEN 1 AND 999
Footnote:
If you are using a variable for your table name (which could be a possibility, without seeing full code), use the following, IF this is the case; many do.
$tblname = "your_table_name";
mysql_query("DELETE FROM `".$tblname."` WHERE @i IN (1000,ROW_COUNT()) ORDER BY points DESC");
You should also consider using mysqli_*
functions with prepared statements or PDO. The mysql_*
functions are deprecated and will be removed from future releases.