views:

56

answers:

2

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

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

I dont get the first five records why?

+4  A: 

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
Sam152
dude, i checked out your profile yesterday in that coined-a-jagon thread. Your momma picture made me DIE of laughter. I was immobilized by a good few minutes.
acidzombie24
Yeah, that picture had the same effect on me when I first saw it.
Sam152
+2  A: 

Use ORDER BY

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