I’m using PostgreSQL 14.13.
Here is a fiddle for it: https://www.db-fiddle.com/f/wtCiz8QtBSkZ3WyS8vRDkQ/0
I have this query that orders cards in a smart way for students
select setseed(-0.07687704123439676);
SELECT cards.id,
dc.deck_id,
cards.question,
cards.answer,
uc.practice_session_sr_level
FROM cards
LEFT JOIN decks_cards dc ON cards.id = dc.card_id
LEFT JOIN user_card uc ON cards.id = uc.card_id
WHERE dc.deck_id = 2907
GROUP BY cards.id,
uc.practice_session_sr_level,
dc.deck_id
ORDER BY
-- cards.id = 98486 desc,
practice_session_sr_level = 'NOT_LEARNED' DESC,
practice_session_sr_level = 'AGAIN' DESC,
practice_session_sr_level = 'HARD' DESC,
practice_session_sr_level = 'EASY' DESC,
practice_session_sr_level = 'GOOD' DESC,
RANDOM()
LIMIT 10 OFFSET 0;
which gives me a result like this:
98512,2907,How do you say 'family'?,rodzina,NOT_LEARNED
98498,2907,How do you say 'teacher' in Polish?,nauczyciel,NOT_LEARNED
98580,2907,What is the Polish word for 'forest'?,las,NOT_LEARNED
98486,2907,How do you say 'friend' in Polish?,przyjaciel,NOT_LEARNED
98525,2907,What is the Polish word for 'heart'?,serce,NOT_LEARNED
98528,2907,How do you say 'solution' in Polish?,rozwiązanie,NOT_LEARNED
98497,2907,What is the Polish word for 'school'?,szkoła,NOT_LEARNED
98540,2907,How do you say 'drink' in Polish?,napój,NOT_LEARNED
...
I would like to enable the user to press on a card and start learning from that card onward.
For example, if the user press the card with id 98486
, it should skip the cards before that one.
If I uncomment cards.id = 98486 desc,
I get
Current result
98486,2907,How do you say 'friend' in Polish?,przyjaciel,NOT_LEARNED
98512,2907,How do you say 'family'?,rodzina,NOT_LEARNED
98498,2907,How do you say 'teacher' in Polish?,nauczyciel,NOT_LEARNED
98580,2907,What is the Polish word for 'forest'?,las,NOT_LEARNED
98525,2907,What is the Polish word for 'heart'?,serce,NOT_LEARNED
98528,2907,How do you say 'solution' in Polish?,rozwiązanie,NOT_LEARNED
98497,2907,What is the Polish word for 'school'?,szkoła,NOT_LEARNED
98540,2907,How do you say 'drink' in Polish?,napój,NOT_LEARNED
...
expected result
98486,2907,How do you say 'friend' in Polish?,przyjaciel,NOT_LEARNED
98525,2907,What is the Polish word for 'heart'?,serce,NOT_LEARNED
98528,2907,How do you say 'solution' in Polish?,rozwiązanie,NOT_LEARNED
98497,2907,What is the Polish word for 'school'?,szkoła,NOT_LEARNED
98540,2907,How do you say 'drink' in Polish?,napój,NOT_LEARNED
...
How can I update the query so PostgreSQL can skip the rows before the specified id?
6