Answer the question
In order to leave comments, you need to log in
How to create a request?
There is a table of users in which, for example, 261 users
There is a page on which these users are displayed, they are sorted by id_user ASC
and broken into pages (10 users per page)
Let's say my id_user=32, and when I go to the users page, I want to see myself on page 3 and second in a row.
something like this:
31. someone there
32. me
33. someone there
34. someone there
35. someone there
36. someone there
37. someone there
38. someone there
39
.someone there 40.someone
there
Answer the question
In order to leave comments, you need to log in
select ROW_NUMBER() OVER(ORDER BY id_user asc), ...over fields FROM MyTable
SET @n=0;SELECT @n:[email protected]+1 AS number, user FROM users ORDER BY user_id; - Something like that.
SELECT id_user, name_user
FROM tbl
WHERE id_user > (
SELECT trnnc(id_user, -1)
FROM tbl
WHERE name_user = :user_name
)
AND id_user <= (
SELECT trnnc(id_user, -1) + 10
FROM tbl
WHERE name_user = :user_name
)
ORDER BY id_user;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question