I have 3 tables: table_A, table_B and table_C. Table_A has a Primary key and is referred by a foreign key from table_B. Table_C has a primary key referred by a foreign key from table_B. The design is like this:
Table_A: ID_A TextData
Table_B: ID_B ID_A ID_C
Table C: ID_C TextData
I want to join between 3 tables like this:
select A.ID_A, A.TextData as DataA, ( select C.TextData from Table_B B, Table_C C where B.ID_C = C.ID_C and B.ID_A = C.ID_A ) as Data_C from Table_A;
I know that it should be an error if I try to compile it with error like: return more than one elements.
But my client want me to join all data from table C into one row, all i know using concate to every data. But i don't know how to do it. I never try to create function or package on oracle. Can you help me how to fix my query?
The result should be like:
ID_A | DataA | Data_C 1 texta text1, text2, text8 2 textb text2, text3, text9 3 textc text1, text8, text9