How to make a selection from two tables?

Good day,

There are two tables:
Table A:
Autokey Name

Table B:
Autokey, RefId, Name

And

Data table:
Autokey, TypeId, SubTypeId

Where is the connection with two other established so:
TypeId = [A].AutoKey -- Field type
SubTypeId = [B].AutoKey -- subtype Field

Table a stores data types
table B stores the subtype-specific data type, i.e. the value of the field [B].RefId is [A].Autokey.
Table C has two fields to identify the type and subtype of the data, while the subtype has only some
types, so SubTypeId can be empty.

Task:
Need to organize data filtering in C
bringing you the choice list, where type and subtype.

Such lists:
Types:
  • Type 1
  • Type 2
  • Type 3


Subtypes:
  • Type 2 - Subtype 1
  • Type 2 - Subtype 2
  • Type 3 - Subtype 4
  • Type 3 - Subtype 5


User 1 sees the attack. list:
  • Type 1
  • Type 2
  • Subtype 1
  • Subtype 2
  • Type 3
  • Subtype 4
  • Subtype 5
Question:
How can I make such a sample?
SQL having:
A. AutoKey, Autokey B., [A][B].Name?
June 14th 19 at 20:03
1 answer
June 14th 19 at 20:05
Solution
If I understand correctly,
A. select AutoKey, Autokey B., A. Name as NameA ,B. Name as NameB, nvl(B. Name, A. Name) as Name
from Tablitas
left join of Tablica
on A. Autokey=C. TypeId
left join Tablesaw B
on B. Autokey=C. SubTypeId

In General, a little bit strange structure. And the question you have to ask linear. If you call the table "table A", and then in the example pseudo-query it is better to write at least a "Tablica", etc..
Can offer a different structure? - abigail36 commented on June 14th 19 at 20:08
the structure table in the tree view.
id, name, id_parent
1 Type 1
2 Type 2
3 the Subtype 1 2
Subtype 4 2 2
....
I think the meaning is clear.
You can leave A and b (but as for me in too then it will be a reference to A)
But instead to make a tree-type of my example. In General, to play with this as best as it is more convenient to you.
Tree traversal in Oracle using connect by ... prior ... start with ... - donna_Okuneva commented on June 14th 19 at 20:11
,
But instead to make a tree-type of my example.

Will not work. There are more than 300 million records. And in the archival and total more. - abigail36 commented on June 14th 19 at 20:14

Find more questions by tags PL/SQLDatabasesSQL