#### Topic: Search in a tree

Good afternoon!
Let there is a tree.
It is necessary to find three words in a tree that they would lie on one branch. How such do in sql?

#### Re: Search in a tree

wrote:

And you truth consider, what it is possible made to answer this question something?
What tree? What words? Trees of that? At what here SQL? If SQL, what data scheme? If SQL, what ?

Structure normal for a tree:
id, parent_fk, name. Search is carried out across the field name.

#### Re: Search in a tree

wrote:

And you truth consider, what it is possible made to answer this question something?
What tree? What words? Trees of that? At what here SQL? If SQL, what data scheme? If SQL, what ?

The approach to such search interests.

#### Re: Search in a tree

The approach idle time: usage of recursive CTE.

#### Re: Search in a tree

Dimitry Sibiryakov wrote:

the Approach idle time: usage of recursive CTE.

And of a recursion gets rid it is possible?

#### Re: Search in a tree

It is possible. Replacing storage structure on nested set or other, ground under trees. Or to enter a field of the materialized full path.

#### Re: Search in a tree

[quote = __ Avenger __] it is passed...
And of a recursion gets rid it is possible?

It is necessary to begin probably not with the middle and from bases. And to recall that there are 3 forms
Representation  in a DB. Inverse lists, Nested sets, And  ways.
It is possible to assume certainly that the author wants a variant No1 but it would be desirable to specify at once.
Concerning branches, , a bar and other drank-materials. Well there is no such. It is not accepted
Such terminology!
There is a root. There are nodes. Also there are sheet nodes. Also there is a concept of level (level) in a tree.
Cornu corresponds the least level.
For a cutoff of all nodes in the inverse list it is possible to use the virtual column level
Type:

``.... WHERE level=N....``

Or

``....GROUP by level``

About a recursion in SQL to speak . It simply is not defined as the actor of this system.
Can consider that it is not present.