I am trying to understand how DUAL, which from my understanding, is used to calculate an equation (SELECT (4+3) FROM DUAL;), can be used create a table as well. Given these two tables, “Items” and “Items_Related”:
Items:
Item_Number
24-1
24-2
24-3
24-4
24-5
Items_Related:
Master_Item Related_Item
24-1 24-2
24-1 24-3
24-1 24-4
24-1 24-5
24-2 24-1
24-3 24-1
24-4 24-1
24-5 24-1
How can the following query:
SELECT
ITEMS.ITEM_NUMBER,
(SELECT DATABASE.ROWS_TO_HTML (SELECT RELATED_ITEM
|| FROM ITEMS_RELATED
|| WHERE ITEMS_RELATED.MASTER_ITEM = ``` || ITEMS.ITEM_NUMBER || ```` || `` ||
ORDER BY ITEMS_RELATED.RELATED_ITEM`) FROM DUAL) AS RELATED_ITEM
FROM ITEMS
;
create this table, where 24-1 in the ITEM_NUMBER field is one merged cell when the table is exported as an Excel spreadsheet, and the rest are all separate:
ITEM_NUMBER RELATED_ITEM
24-1 24-2
24-3
24-4
24-5
24-2 24-1
24-3 24-1
24-4 24-1
24-5 24-1
When I tried to input a test query into oracle SQL developer, such as:
SELECT (‘SELECT ITEM_NUMBER’ || ‘FROM ITEMS’) FROM DUAL;
the result was:
‘SELECT ITEM_NUMBER…..
SELECT ITEM_NUMBERFROM ITEMS
Ntdesign is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.