Hi I got some problems with the following Query
SELECT *
FROM PARTNER P
, ADDRESS A
,DOSSIERPARTNERRELATIONSHIP DPR
LEFT JOIN PARTNERHIST PH ON P.ID=PH.PARTNER_ID
WHERE (P.NAME ='Burger' OR PH.NAME='Burger')
AND P.ID = DPR.PARTNER_ID
AND A.PARTNER_ID = P.ID
;
when I'm trying to execute it I got the following error:
ORA-00904: "P"."ID": invalid identifier
Also when I'm trying the following I got the same error
SELECT *
FROM PARTNER P
, ADDRESS A
,DOSSIERPARTNERRELATIONSHIP DPR
LEFT JOIN PARTNERHIST PH ON PARTNER.ID= PH.PARTNER_ID
WHERE (P.NAME ='Burger' OR PH.NAME='Burger')
AND P.ID = DPR.PARTNER_ID
AND A.PARTNER_ID = P.ID
;
Ora-00904 Error Message “Invalid Identifier” This error is most common when querying a SELECT statement. To resolve this error, first check to make sure the column name being referenced exists. If it does not exist, you must create one before attempting to execute an SQL statement with the column.
The plus sign is Oracle syntax for an outer join. There isn't a minus operator for joins. An outer join means return all rows from one table. Also return the rows from the outer joined where there's a match on the join key. If there's no matching row, return null.
Left Outer Join: Left Outer Join returns all the rows from the table on the left and columns of the table on the right is null padded. Left Outer Join retrieves all the rows from both the tables that satisfy the join condition along with the unmatched rows of the left table. SELECT [column1, column2, ....]
The SQL LEFT JOIN returns all rows from the left table, even if there are no matches in the right table. This means that if the ON clause matches 0 (zero) records in the right table; the join will still return a row in the result, but with NULL in each column from the right table.
Try this:
SELECT *
FROM PARTNER P
INNER JOIN ADDRESS A ON A.PARTNER_ID = P.ID
INNER JOIN DOSSIERPARTNERRELATIONSHIP DPR ON P.ID = DPR.PARTNER_ID
LEFT JOIN PARTNERHIST PH ON P.ID= PH.PARTNER_ID
WHERE (P.NAME ='Burger' OR PH.NAME='Burger')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With