Queary range of data in MySQL database? 11 Years, 7 Months ago
|
Karma: 0
|
Hi
I have many sets of data using the same column structure and therefor easily are placed in the same table in my MySQL database. This makes upload, maintenance and editing much easier.
I would like to set up a set of modules, each getting a specific range of data from that table.
First module should display data from row 3 to 53, second module should display data from row 60 to 120 and so on.
In total I will have a very large table with more than 10.000 rows but I never want to display all of these, I just need the ranges. I want the data that is displayed on the site in each module to be sortable as usual of course.
Can you please explain how I need to set up the query to make this possible?
Best Regards
Johan Niklasson
|
|
|
|
|
Re:Queary range of data in MySQL database? 11 Years, 7 Months ago
|
Karma: 760
|
Hello,
Are row numbers stored in database?
Regards,
ARI Soft
|
|
|
|
|
Re:Queary range of data in MySQL database? 11 Years, 7 Months ago
|
Karma: 0
|
Hi
Yes, I will have it all set up so that row numbers are stored (or at least a field id number that would do the same thing). The data is static - it will not be updated very often so row numbers will always be the same.
Best Regards
Johan Niklasson
|
|
|
Last Edit: 2013/04/10 06:59 By Evopro.
|
|
Re:Queary range of data in MySQL database? 11 Years, 7 Months ago
|
Karma: 760
|
For example if row number is stored in "RowIndex" column, it is possible to use the following SQL query to show rows from 1 to 30:
SELECT
*
FROM
tbl
WHERE RowIndex BETWEEN 1 AND 30
Regards,
ARI Soft
|
|
|
|
|
Re:Queary range of data in MySQL database? 11 Years, 7 Months ago
|
Karma: 0
|
Hi
Thanks for that.
I have tried to use it and it looks like this:
SELECT top50_all.id,
top50_all.rank,
top50_all.result_in_pounds,
top50_all.result_in_kilos,
top50_all.x_bwt,
top50_all.name_yob,
top50_all.date,
top50_all.actual_weight_body_weight,
top50_all.note,
top50_all.location,
top50_all.federation
FROM top50_all.id WHERE RowIndex BETWEEN 3 AND 52
ORDER BY top50_all.rank ASC
But it does not work. Can you see anything immediately wrong with it?
Best Regards
Johan Niklasson
|
|
|
|
|
Re:Queary range of data in MySQL database? 11 Years, 7 Months ago
|
Karma: 760
|
Hello,
"RowIndex" in our previous post was a sample name, use column name which contains row index in your table.
Use also "FROM top50_all" instead of "FROM top50_all.id".
Regards,
ARI Soft
|
|
|
|
|
|