Let’s just say I have tree in my table called “page”:
Foo
-- Bar 1
-- Bar 2
-- Bar 3
-- Some foo
-- Some value
Bar
-- Bar 4
I want to search by node’s name. For example “bar%”. Excpected output should be:
Foo
-- Bar 1
-- Bar 2
-- Bar 3
Bar
-- Bar 4
I can’t find solution to write right query in MySQL. Searching is not a problem – I don’t know how to get a depth of a node in search results.
This query can be improved if you create your
(lft, rgt)‘s as a single fieldsets LineStringand make aSPATIAL INDEXover this field:See this article for more details: