I have a SQL query which retrieve wall post list
$qry=mysql_query("SELECT senderid,post,date FROM ".post_table." WHERE id='".$mydata->id."' ORDER BY time DESC LIMIT 0, 20");
This is working good. But I’ve now a problem:
If a user post 20 post at the same time, then the first list will show only his post. But I want to show 1 post from one user at the first list. So I’m trying to use the below statement:
$qry=mysql_query("SELECT senderid,post,date FROM ".post_table." WHERE id='".$mydata->id."' ORDER BY time DESC, DISTINCT(senderid) LIMIT 0, 20");
which is not working at all.
please help me how I can do it ?
use distinct in select clause not in where. try