Consider this forum page where we are placing all our queries.In each page there are about 40 questions.The Page no are given below as Page 12345678>> like this when we click on the respective page no it will show the respective page which contains around 40 queries in that page.How this is done using java code or any sql statments ?
Give me example code and detailed explanation in this.
Ok, suppose you have a database containing the topics, with one row in a table for each topic.
If you know that you want to display 40 topics per page, you can find out the number of pages by executing an SQL query like this:
SELECT COUNT(*)/40 FROM TOPICS
If you want to select the topics from a specific page, you'll have to specify this in the SQL statement, but unfortunately there is no (AFAIK) standard way to do this in SQL. In MySQL, you can use the LIMIT keyword like this:
SELECT * FROM TOPICS ORDER BY timestamp LIMIT 120,40
This selects 40 rows, beginning with row number 120 that the query itself returns, but as I wrote, it's MySQL specific SQL syntax.
In Oracle you'd have to do things with ROWNUM, and in other databases it works differently again.
So, look it up in the documentation for your particular database. [ October 19, 2005: Message edited by: Jesper de Jong ]
Hi Jesper de Jong I understood the putting the topics in n no of pages but i couldn't get it the second part.If the user click on the particular page how it wil get the things in on that specific page.Bcos in the second u placed 120 as the beginning row but in the run-time it may vary how it done.This same kind of scenario u could find in Google Search also there u may n no of pages but if we click on particular page it shows the particular page details.Pleae tell me more abt it.