分页sql查询语法 [英] pagination sql query syntax

查看:60
本文介绍了分页sql查询语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试按日期对我的讨论区中的帖子进行排序.这是我的代码:

I am trying to sort my posts in my discussion board by date. Here is my code:

$query = mysql_query("SELECT * FROM {$statement} 
LIMIT {$startpoint} , {$limit} 
ORDER BY datetime ASC");

这在语法上有什么问题吗?如果没有,还有什么可能是错误的?基本上发生的是结果没有显示出来.我删除了Order by,并且可以使用(但是当然没有排序...)

Is there anything syntactically wrong with this? If not, what else could be wrong? Basically what is happening, is that the results are not showing up. I remove the Order by, and it works (but of course it's not sorted...)

推荐答案

排序依据应超出限制:

$query = mysql_query("SELECT * FROM {$statement} 
ORDER BY datetime ASC LIMIT {$startpoint} , {$limit}");

这篇关于分页sql查询语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆