2

I want to retrieve the last three children of my parent. Currently the statement reads:

SELECT * 
from replies 
order by rID,rValue 

Because rValue signifies the reply mechanism a null rValue means that is the parent. To allow replies to replies rValue goes x to x.999999 and I was hoping there is some way to retrieve the last three results for each parent. Please hit me up if any further clarification is required.

EDIT: Lets say a limit of 30 thread per page and a maximum of 1000replies per thread would it be a huge strain on the DB just to get all the results then cycle through to the last 3 of each?

1

1 Answer 1

0

You need common table expression and recursive queries. Take a look at your RDBMS if it supports them.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.