I have a query that works in phpMyAdmin but not when being run through php
This is the query:
DELETE FROM 'table' WHERE 'id' NOT IN ( SELECT DISTINCT id FROM ( SELECT * FROM 'table' ORDER BY scoreDESC LIMIT 10 ) foo)
Basically, it sorts the table to score descending and then keeps the top 10 and deletes the rest. I can run this fine trough phpmyadmin but my php code says no
This is the php script:
function add_highscore()
{
mysql_query("DELETE FROM highscores WHERE id NOT IN ( SELECT DISTINCT id FROM ( SELECT * FROM highscores ORDER BY score DESC LIMIT 10 ) foo)")
or die('0');
echo "1";
mysql_close($table_id);
}
There is no problems with the connection, I have more functions in the script that works.
Any ideas? Help is greatly appreciated!
Cheers, Jon