Mysql limit function doesn't seem to work for me
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开发者_JAVA技巧='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?
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
Use ORDER BY
and t1.dIsDelete='0'
ORDER BY 't1.dSyllabus_id'
limit 0,5
精彩评论