Requirement for the query

Hi all

I'm using Oracle 11.2.0.3

CREATE TABLE PRODUCT (ID NUMBER, PRODUCT_CODE VARCHAR2 (30));

INSERT INTO THE PRODUCT VALUES (1, 'CAR1');

INSERT INTO THE PRODUCT VALUES (2, 'CAR2');

INSERT INTO THE PRODUCT VALUES (3, 'CAR3');

INSERT INTO THE PRODUCT VALUES (4, 'CAR4');

INSERT INTO THE PRODUCT VALUES (5, 'CAR5');

CREATE TABLE ITEM_STG (ITEM_CODE VARCHAR2 (30), ITEM_DESC VARCHAR2 (200));

INSERT INTO ITEM_STG VALUES ('CAR1', 'MARUTI');

INSERT INTO ITEM_STG VALUES ('CAR2', 'AUNTIE');

CREATE TABLE AN ELEMENT (ITEM_CODE VARCHAR2 (30), ITEM_DESC VARCHAR2 (200));

INSERT INTO ARTICLE VALUES ('CAR1', 'BMV');

INSERT INTO ARTICLE VALUES ('CAR2', 'BENZ');

INSERT INTO ARTICLE VALUES ('CAR2', 'LANDROVER');

INSERT INTO ARTICLE VALUES ('CAR2', 'JAGUAR');

My requirement is like I make a query

so that it checks the product code with the item code

and first he will get the values of the table ITEM_STG if the value of patcular is not found in the table ITEM_STG then it goes to the table ARTICLE

can it be possibel in simple sql query

SELECT A.PRODUCT_CODE, NVL (B.ITEM_DESC, C.ITEM_DESC)

THE PRODUCT,.

B ITEM_STG,

POINT C

WHERE A.PRODUCT_CODE = B.ITEM_CODE

AND A.PRODUCT_CODE = C.ITEM_CODE

I tried like the query above and with left join and other possibilities, but getting not the query.

Please help me

Thank you

You were close...

SQL> ed
Wrote file afiedt.buf                                              

  1  select a.product_code, nvl(b.item_desc, c.item_desc) item_desc
  2  from product a, item_stg b, item c
  3  where a.product_code = b.item_code ( + )
  4* and a.product_code = c.item_code
SQL> /                                                            

PRODUCT_CODE
------------------------------
ITEM_DESC
---------------------------------------------------------------------
CAR1
MARUTI                                                            

CAR2
TATA                                                              

CAR4
JAGUAR                                                            

PRODUCT_CODE
------------------------------
ITEM_DESC
---------------------------------------------------------------------
CAR3
LANDROVER                                                         

Note: remove space (+)

Grrr... stupid software

Tags: Database

Similar Questions

Maybe you are looking for

  • 9.3 IOS sort does not

    Anyone else having the problem of sorting in iBooks / my books/authors or by default in the given name/initials of the author rather than the name of sorting (name, first name) specified in iTunes? Just mess when you have a lot of books on the device

  • Difference of 1866Ghz crucial memory?

    I was looking for a 16 gb memory kit for an iMac 27 "5 k end of 2015. I found these crucial with the same characteristics, but they are different and have different model numbers: Crucial CT2KIT102464BF186D (from different shops that sell Crucial) Cr

  • HP 15 r204ne: r204ne 15 hp ram slots how this laptop has one or two

    When I checked my ram I found only 4 GBNow I want to upgrade my ramIs that my laptop (hp 15 r204ne) has one or two slots of ram and what is the maximum memory I can update in every situation My operating system is Windows Home Edition unilingual 64 1

  • Desktop computer can not detect the wireless router, even with adapter

    Hello I broke my laptop so I got out my old office since 2003. Its a gateway computer. There was no place where to connect my internet wire so I went out and bought a usb wireless adapter and updated my computer to Windows XP Home Edition. I put the

  • Xperia SP

    I use xperia SP this is going to be my last sony mobile if there is no update of kitkat for SP that you are deceiving us, before, I bought my sp I noticed the version recommended SP was kitkat. but now the more recent & final version was frozen bean