-
All,
Please forgive me for posting my question as a reply to the one previously asked. Since i am very new to this forum i got struck with how to post a message to this list.
I got a problem with my sql query can anyone please help me out
Here is the description of all the 3 tables from where i am getting my data
FIRS TABLE
Name Null? Type
***************************************************FIR_ID NOT NULL NUMBER
FIR_IDR NOT NULL VARCHAR2(4)
WORLD_AREA_CD VARCHAR2(3)
FIR_NAME NOT NULL VARCHAR2(25)
FIRS_COUNTRY_CODES
Name Null? Type
***************************************************
FIR_COUNTRY_CODE_ID NOT NULL NUMBER
FIR_ID NOT NULL NUMBER
COUNTRY_CODE_ID NOT NULL NUMBER
COUNTRIES TABLE
------------------
Name Null? Type
***************************************************
COUNTRY_ID NOT NULL NUMBER
COUNTRY_ISO_CD VARCHAR2(2)
COUNTRY_NAME VARCHAR2(25)
when i execute this query it is working fine
select FIR_ID from FIRS where FIR_IDR= 'FF' AND FIR_NAME= 'FIR' AND
WORLD_AREA_CD= 'EXC'
but when i execute this query
Select c.FIR_ID from FIR_COUNTRY_CODES a, COUNTRIES b, FIRS c wh
ere c.FIR_IDR= 'FF' AND c.FIR_NAME= 'FIR' AND c.WORLD_AREA_CD= 'EXC'
can anyone please please explain me where i am going wrong.
Please help guys,
Seenu
-
cartesian product
You have no predicate in your WHERE clause to join the tables a,b and c, with means that every row of each table joins to the other. This is called a cartesian product.
Try adding to oyur where clause:
AND A.FIR_ID = C.FIR_ID
AND A.COUNTRY_CODE_ID B.COUNTRY_ID
Gerry