#### 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?

You are not logged in. Please login or register.

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?

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.

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.

The approach idle time: usage of recursive CTE.

Dimitry Sibiryakov wrote:

the Approach idle time: usage of recursive CTE.

And of a recursion gets rid it is possible?

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

[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.

mayton wrote:

About a recursion in SQL to speak .

Can consider that it is not present.

In "pure" SQL is not present... But here in extensions, type T-SQL (in a type with... select...), very much even is...

__ Avenger __;

The such do not do in SQL.

a C. wrote:

in "pure" SQL is not present...

Is. WITH RECURSIVE enters in ANSI standard SQL.

**Random topics**