I have two table. Department is hierarchical table.
--- id (int primary key)
--- name (varchar)
--- parent (int)
This query return all data from departments. But i cannot understand how get data from users
SELECT t1.name AS lvl1, t2.name as lvl2, t3.name as lvl3
FROM Department AS t1
LEFT JOIN Department AS t2 ON t2.parent = t1.id
LEFT JOIN Department AS t3 ON t3.parent = t2.id
90% of the solution is the correct identification of the problem. What do you want the output to look like and how do you want it grouped?
My recommendation is to provide some data in a readily consumable format. Please don't assume how to do that. Please see the first link in my signature line below under "Helpful Links". Once you have that data, then provide an example of how you want that data to look.
is pronounced ree-bar and is a Modenism for R
First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
Although they tell us that they want it real bad, our primary goal is to ensure that we dont actually give it to them that way.
Although change is inevitable, change for the better is not.
Just because you can do something in PowerShell, doesnt mean you should. Helpful Links:
How to post code problemsHow to post performance problemsForum FAQs