按ID MYSQL排序

时间:2018-05-28 01:27:57

标签: php mysql

我这里有我的代码

$query=mysqli_query($dbcon,"select count(user_name) from `viewlist` where user_name='$_name'");

我想要做的是它只显示带有用户名$_name的列,但是将它排列在通过id递减的表上(这是自动递增)。我尝试按照DESC订购,但没有工作。

1 个答案:

答案 0 :(得分:-2)

也许..

$query=mysqli_query($dbcon,"select tb.* from (select count(user_name) as total from `viewlist` group by user_name) as tb order by tb.total desc");