samedi 15 novembre 2014

How to update a column with values depending upon conditions - Oracle


Vote count:

0




My requirement is to update a column with 'Y' if a set of conditions are met or with 'N'. I want to do it in the same query.


For example :





CREATE TABLE TAB1 (COL1 INT, COL2 INT);

CREATE TABLE TAB2 (COL1 INT);

INSERT INTO TAB1 VALUES(1, 3);
INSERT INTO TAB1 VALUES(2, 3);

INSERT INTO TAB2 VALUES(1);

INSERT INTO TAB2 VALUES(1);



I want to update the COL2 of TAB1 with 'Y' if TAB1.COL1 matches with the TAB2.COL1 or COL2 should be updated with 'N'. This of course a simple example and the actual requirement far more complex. I know there must be a simple solution to this but I am not getting it. Can you please help.



asked 2 mins ago







How to update a column with values depending upon conditions - Oracle

Aucun commentaire:

Enregistrer un commentaire