razvypp Posted April 8, 2010 Share Posted April 8, 2010 can any one tell me why i get error ? $s = "Select * from chat_global order by id ASC"; (works) but as soon as i add 'Top 3' ,like below $s = "Select Top 3 * from chat_global order by id ASC"; 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 '3 * from chat_global order by id ASC' at line 1 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in Q:\www\chat.php on line 24 Quote Link to comment Share on other sites More sharing options...
Deoctor Posted April 8, 2010 Share Posted April 8, 2010 i dont think top will work under mysql. it works in the sql server.. try some thing like this SELECT DISTINCT( `cloumnA` ), COUNT( `columnA` ) FROM `tablename` GROUP BY 1 ORDER BY 2 DESC LIMIT 0,10; Quote Link to comment Share on other sites More sharing options...
razvypp Posted April 8, 2010 Author Share Posted April 8, 2010 but i need more fields to be selected not only one , and i want it for a chat , so the last entry should be the last printed , so order should be ASC not DESC , any one have a solution ? Quote Link to comment 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.