A
A
Alexey2017-07-20 21:15:43
MySQL
Alexey, 2017-07-20 21:15:43

How to make such query in MYSQL database?

I have a table in the database that contains many records belonging to different users (this is determined by the owner column, where the user's id is indicated).
There is a task to display all user records from this table page by page.
I solved this problem by getting a list of all user records and then using php I took only 10 records (if it is set that there are 10 records on one page), but in cases where there is a lot of data, then php triggers a memory limit and an error pops up .
It would be nice if we could immediately take from the database, for example, only 10 records of this user, but depending on which page is open.
Is it possible to make such a request, where all the user's records from the table would be taken and, plus, all that are not needed at the moment, since the user is on a specific page, are eliminated.
The query is something like "SELECT * FROM users_data WHERE owner=ID". But for example, if page 2 is open, and there are records on page 10, then you need to take records from there on the account from 10 to 20, and the rest are not needed

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniel Besedny, 2017-07-20
@mr-alexey

SELECT * FROM users_data WHERE owner=id LIMIT 10,20 will print from 10 to 20
LIMIT

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question