Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid Identifier on Sql left join oracle

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
 ;
like image 595
tung Avatar asked Dec 17 '14 13:12

tung


People also ask

How do I fix an invalid identifier in Oracle?

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.

What does (+) mean in Oracle join?

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.

How can I check left outer join?

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, ....]

WHAT IF LEFT join is null?

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.


1 Answers

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')
like image 172
Saharsh Shah Avatar answered Oct 29 '22 21:10

Saharsh Shah