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?

a_horse_with_no_name
  • 497,550
  • 91
  • 775
  • 843
Matt
  • 429
  • 3
  • 11

1 Answers1

0

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

Pablo Santa Cruz
  • 170,119
  • 31
  • 233
  • 283