My boss found an error in the request that I created, and I do not understand the cause of the error, although the results of the request confirm its correctness. Here's the request (simplified version) before fixing:
select PTNO,PTNM,CATCD from PARTS left join CATEGORIES on (CATEGORIES.CATCD=PARTS.CATCD);
and after correction:
select PTNO,PTNM,PARTS.CATCD from PARTS left join CATEGORIES on (CATEGORIES.CATCD=PARTS.CATCD);
The error was that zero values ​​were shown for the CATCD column, that is, the query results included the results from the CATEGORIES table instead of PARTS. Here's what I don’t understand: if there was ambiguity in the original query, why didn’t Oracle throw an error? As I understand it, in the case of left joins, the "main" table in the query (PARTS) takes precedence over ambiguity. Am I mistaken, or just do not think about this problem correctly?
Update:
Here is a revised example where an ambiguity error is not thrown:
CREATE TABLE PARTS (PTNO NUMBER, CATCD NUMBER, SECCD NUMBER); CREATE TABLE CATEGORIES(CATCD NUMBER); CREATE TABLE SECTIONS(SECCD NUMBER, CATCD NUMBER); select PTNO,CATCD from PARTS left join CATEGORIES on (CATEGORIES.CATCD=PARTS.CATCD) left join SECTIONS on (SECTIONS.SECCD=PARTS.SECCD) ;
Does anyone have a key?
Ovesh source share