Mysql限制功能似乎对我不起作用

发布于 2024-09-02 21:15:56 字数 1071 浏览 2 评论 0原文

这是我的查询,

select t1.dSyllabus_id,t1.dBatch,t1.dFilePathName,
t2.dDegreeName,t3.dDepartmentAbbr
from tbl_syllabus as t1
join tbl_degree_master as t2,
tbl_department_master as t3
where t2.dDegree_id=t1.dDegree_id 
and t3.dDepartment_id=t1.dDepartment_id
and t1.dCollege_id='1'
and t1.dIsDelete='0'

我得到

无限制 http://img534.imageshack.us/ img534/2165/withoutlimi.jpg

应用限制,

 select t1.dSyllabus_id,t1.dBatch,t1.dFilePathName,
    t2.dDegreeName,t3.dDepartmentAbbr
    from tbl_syllabus as t1
    join tbl_degree_master as t2,
    tbl_department_master as t3
    where t2.dDegree_id=t1.dDegree_id 
    and t3.dDepartment_id=t1.dDepartment_id
    and t1.dCollege_id='1'
    and t1.dIsDelete='0'
    limit 0,5

我得到,

有限制 http ://img13.imageshack.us/img13/2470/withlimit.jpg

我没有得到前五个记录,为什么?

Here is my query,

select t1.dSyllabus_id,t1.dBatch,t1.dFilePathName,
t2.dDegreeName,t3.dDepartmentAbbr
from tbl_syllabus as t1
join tbl_degree_master as t2,
tbl_department_master as t3
where t2.dDegree_id=t1.dDegree_id 
and t3.dDepartment_id=t1.dDepartment_id
and t1.dCollege_id='1'
and t1.dIsDelete='0'

and i get

Without Limit http://img534.imageshack.us/img534/2165/withoutlimi.jpg

applying limit ,

 select t1.dSyllabus_id,t1.dBatch,t1.dFilePathName,
    t2.dDegreeName,t3.dDepartmentAbbr
    from tbl_syllabus as t1
    join tbl_degree_master as t2,
    tbl_department_master as t3
    where t2.dDegree_id=t1.dDegree_id 
    and t3.dDepartment_id=t1.dDepartment_id
    and t1.dCollege_id='1'
    and t1.dIsDelete='0'
    limit 0,5

i get ,

With Limit http://img13.imageshack.us/img13/2470/withlimit.jpg

I dont get the first five records why?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

痴骨ら 2024-09-09 21:15:56

您获得了 5 条记录,但您尚未下订单。除非您也告诉他们,否则他们不会按特定顺序返回。就你而言,我相信你希望它们按照 ID 的顺序排列。添加类似的内容:

order by `t1`.`dSyllabus_id` ASC

因此您的查询如下所示:

select t1.dSyllabus_id,t1.dBatch,t1.dFilePathName,
t2.dDegreeName,t3.dDepartmentAbbr
from tbl_syllabus as t1
join tbl_degree_master as t2,
tbl_department_master as t3
where t2.dDegree_id=t1.dDegree_id 
and t3.dDepartment_id=t1.dDepartment_id
and t1.dCollege_id='1'
and t1.dIsDelete='0'
order by `t1`.`dSyllabus_id` ASC
limit 0,5

You get 5 records, but you haven't set an order. They will not come back in a specific order unless you tell them too. In your case I believe you want them in order of their id. Add something like:

order by `t1`.`dSyllabus_id` ASC

So your query looks like:

select t1.dSyllabus_id,t1.dBatch,t1.dFilePathName,
t2.dDegreeName,t3.dDepartmentAbbr
from tbl_syllabus as t1
join tbl_degree_master as t2,
tbl_department_master as t3
where t2.dDegree_id=t1.dDegree_id 
and t3.dDepartment_id=t1.dDepartment_id
and t1.dCollege_id='1'
and t1.dIsDelete='0'
order by `t1`.`dSyllabus_id` ASC
limit 0,5
笨笨の傻瓜 2024-09-09 21:15:56

使用排序依据

and t1.dIsDelete='0'
    ORDER BY 't1.dSyllabus_id'
    limit 0,5

Use ORDER BY

and t1.dIsDelete='0'
    ORDER BY 't1.dSyllabus_id'
    limit 0,5
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文