1

I am using the query:

select *
from time
where date = '2018-03-10'
limit 0,5;

Here is image of my data

Which I expect to return output from the 1st row, but it skips the first row of data and show result from 2nd row.

I also try

select * from time where date='2018-03-10' order by date limit 5 offset 0;

Everytime i call it offset increased by 5 but the result skip the data ...it donot show me data where name =sss and www...but show the remaining data why???

  • 1
    Please show the table's schema (**not** as an image) and tell us which column(s) define row order. – Bohemian Mar 10 '18 at 15:12
  • Sorry guys for disturbing you ...as this Code works perfect...i have some error in my code – sahil goyal Mar 12 '18 at 06:19
  • if you have another question, ask it as a new question. If my answer answered your question, please "accept" it (click the tick mark on the answer's left) – Bohemian Mar 12 '18 at 06:23

1 Answers1

2

Since you have no order by clause, the definition of what is the "first" row is arbitrary.

To return rows predictably when using limit, you must define the row order by specifying an order by clause, eg:

select *
from time
where date = '2018-03-10'
order by id -- specify whatever column(s) define the order
limit 0,5
Bohemian
  • 412,405
  • 93
  • 575
  • 722