| SQL - Questions and Answers Have a SQL question? Post it here. First do a search to see if someone hasn't already answered it. |
|
|||
subselect to inner joinI was studying nested set model:
MySQL AB :: Managing Hierarchical Data in MySQL Everything goes cool, because of my mysql version, now im having nightmares trying to pass the following subselect to joins, any help is welcome: SELECT node.name, (COUNT(parent.name) - (sub_tree.depth + 1)) AS depth FROM nested_category AS node, nested_category AS parent, nested_category AS sub_parent, ( SELECT node.name, (COUNT(parent.name) - 1) AS depth FROM nested_category AS node, nested_category AS parent WHERE node.lft BETWEEN parent.lft AND parent.rgt AND node.name = 'PORTABLE ELECTRONICS' GROUP BY node.name ORDER BY node.lft )AS sub_tree WHERE node.lft BETWEEN parent.lft AND parent.rgt AND node.lft BETWEEN sub_parent.lft AND sub_parent.rgt AND sub_parent.name = sub_tree.name GROUP BY node.name HAVING depth <= 1 ORDER BY node.lft; Thanks in advanced. |
|
Be the first to answer this question! Click on the 'Post Reply' button below.
|
![]() |
| Thread Tools | Search this Thread |
|
|
LinkBacks (?)
LinkBack to this Thread: http://www.sqlrecipes.com/sql_questions_answers/subselect_inner_join-138/
|
|||
| Posted By | For | Type | Date |
| sql inner join example + inner join definition of inner join in the Free Online Encyclopedia @ JONLOK.INFO | This thread | Refback | 03-29-2008 06:04 PM |