Is it possible to retrieve multiple paths from MySQL nested sets? Emphasis is on the second line of the where condition.
SELECT parent.name
FROM nested_category AS node,
nested_category AS parent
WHERE node.lft BETWEEN parent.lft AND parent.rgt
AND node.name = 'Name1' OR node.name = 'Name2'
ORDER BY node.lft;
Yes, of course.
In
SQL,ORhas lower precedence thanAND, so you need to rewrite the query as:This query is quite inefficient in
MySQLbecause the join condition is not sargable.You may want to store your sets as
LineStringand use spatial indexes to speed up the query.See this entry in my blogs for details: