I am not frequent SQL coder, I use it only for a simple tasks. I want to find a solution for a probably simple problem.
I have two tables:
Master_tbl [fields: ID, Plant, Detail_Group_ID]
and
Detail_tbl [fields: ID, Group_ID, Plant]
With such example data:
Master_tbl:
ID Plant Detail_Group_ID
1 Tree 1
2 Flower 2
Detail_tbl:
ID Group_ID Plant
1 1 Oak
2 1 Apple
3 1 Spruce
4 1 Maple
5 2 Tulip
6 2 Rose
7 2 Violet
8 2 Orchid
I want to make SQL statement to put two tables in one (in master/detail way):
The result table should display data in Treeview like fashion, where master fields are like parent nodes and detail fields like child nodes (see outcome below). I am not really sure, if this could be mastered via SQL…
Plant
Tree
Oak
Apple
Spruce
Maple
Flower
Tulip
Rose
Violet
Orchid
Thanx in advance.
That will give you output like:
Here’s another option:
The output is:
It’s not necessarily the tree you wanted, but I think it’s as close as you can get. In everything I could find, I couldn’t find a way to get the tree output in one column like you posted. However, with these two queries, you can very easily parse the results based on the group.