We have the following sample table (actually taken from another example here in stackoverflow ...)
CREATE TABLE example ( id integer primary key, name char(200), parentid integer, value integer);
And for a specific child we want to get the upper parent.
I know the connectfunc connectby function, but for getting parent children.
But, I'm interested in another direction, given the child, what is his main parent? What type of request would I try and use?
Friendly advice is welcome.
sql postgresql recursion
hooknc
source share