patternMinor
Comma-separated join (cross join)
Viewed 0 times
separatedcrosscommajoin
Problem
I don't understand how this query works:
What does the comma at the start of line #7 do?
My guess is that whoever wrote the query used some sort of SQL short-hand. Perhaps if someone could help re-format the query in 'beginner SQL' it might help.
1 SELECT
2 EXTRACTVALUE(definition_xml.COLUMN_VALUE, 'SubtypeFieldInfo/DomainName') AS domain_name
3 FROM
4 SDE.GDB_ITEMS_VW i
5 JOIN SDE.GDB_ITEMTYPES it ON
6 i.Type = it.UUID
7 ,TABLE(XMLSEQUENCE(XMLType(Definition).Extract('/DETableInfo/Subtypes/Subtype/FieldInfos/SubtypeFieldInfo'))) definition_xmlWhat does the comma at the start of line #7 do?
My guess is that whoever wrote the query used some sort of SQL short-hand. Perhaps if someone could help re-format the query in 'beginner SQL' it might help.
Solution
The comma is the implicit join operator, ANSI SQL-89 syntax. No different than the comma in:
I think you can replace it with
The
The parentheses around the joins and the last table are completely optional. I added them just to show how the query is parsed:
*
select ...
from a , b -- <-- this comma
where a.aid = b.aid;I think you can replace it with
CROSS JOIN*, assuming a recent enough Oracle version.The
i, it and definition_xml are the aliases of the 3 joined tables (the 2 tables are base tables or views and the 3rd is something like a derived table, Oracle calls them "table collection expressions") but they are no different regarding how they can be joined or referenced.The parentheses around the joins and the last table are completely optional. I added them just to show how the query is parsed:
SELECT
EXTRACTVALUE(definition_xml.COLUMN_VALUE, ...) AS domain_name
FROM
( SDE.GDB_ITEMS_VW i
JOIN
SDE.GDB_ITEMTYPES it
ON
i.Type = it.UUID
)
, -- or: CROSS JOIN
( TABLE(...) definition_xml
)
;*
CROSS JOIN and the comma join operator have different precedence but this doesn't matter for the specific query. As a good practice though, it's best not to mix the comma join with explicit JOIN.Code Snippets
select ...
from a , b -- <-- this comma
where a.aid = b.aid;SELECT
EXTRACTVALUE(definition_xml.COLUMN_VALUE, ...) AS domain_name
FROM
( SDE.GDB_ITEMS_VW i
JOIN
SDE.GDB_ITEMTYPES it
ON
i.Type = it.UUID
)
, -- or: CROSS JOIN
( TABLE(...) definition_xml
)
;Context
StackExchange Database Administrators Q#153619, answer score: 6
Revisions (0)
No revisions yet.