我创建了一个包含message, sender, to, time的表,我希望按发件人分组和按时间排序这是我的代码
$query= mysql_query("SELECT * FROM `table` ORDER BY `time` GROUP BY `sender`")or die(mysql_error());
while($arr = mysql_fetch_array($query)){
$num = mysql_num_rows($query);
$msg = $arr ['message'];
echo '</br>';
echo $msg;
}这向我展示了这个错误
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 'GROUP BY发件人' at line 1
那么如何解决这个问题呢?
谢谢
克劳斯
发布于 2013-07-01 08:15:11
请注意您的优先级。对结果进行分组后,应对其进行排序。
"SELECT * FROM `table` GROUP BY `sender` ORDER BY `time`"https://stackoverflow.com/questions/17396021
复制相似问题