I want to get all the metadata values related to a document in a single query, be it with null in some columns.
Example:
DOCUMENT table ATTRIBUTE_1 values ATTRIBUTE_2 values
Id | Name DocId | Value DocId | Value
----------- --------------- ---------------
1 | Doc1 1 | Val1 1 | ValA
2 | Doc2 1 | Val2 1 | ValB
1 | ValC
For Doc1, I want the query to return the values for each attribute ordered alphabetically:
Attr1 | Attr2
--------------------
Val1 | ValA
Val2 | ValB
NULL | ValC
I tried a very naive query:
SELECT a1.Value, a2.Value FROM ATTRIBUTE_1 a1, ATTRIBUTE_2 a2, DOCUMENT d
WHERE d.Id = a1.DocId AND d.Id = a2.DocId AND d.Id = 1
I tried doing inner joins, I tried googling but couldn't find terms which weren't about merging multiple columns in a single one.
The database used is Oracle.
How can I achieve this goal?
Thank you
NULL | ValC?Val1andVal2so that they must appear side-by-side? (the same goes for all pairs in the result)NULL. @geomagas Do you meanVal1andValA? If yes, the columns only need to be sorted alphabetically.Val1, Val2, ...are just examples, becauseVal10will sort beforeVal9.