J
J
jenya77712021-11-29 14:24:25
PostgreSQL
jenya7771, 2021-11-29 14:24:25

How to get 100 entries after an entry with a specific uuid?

Hello, how can I write a query that can get 100 records after a record with a specific id (uuid), and sorted by createdAt?

id(uid) | value(string) | createdAt(timestamp)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
ky0, 2021-11-29
@ky0

See the creation date of the desired entry, use it as a condition, add sorting and LIMIT.

A
Akina, 2021-11-29
@Akina

Use 2 copies of the table. One to get the date by a given UUID, the second to fetch records.

SELECT t1.*
FROM table t1
JOIN table t2 ON t2.uuid = @uuid1 
             AND t1.createdAt > t2.createdAt
ORDER BY createdAt ASC LIMIT 100

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question