How to condition the values for INSERT INTO table2 SELECT FROM table1?
Hi all,
Values in col1 table1 = '0', '1'.
Values in col2 table2 = 'N', 'Y'.
Both column types = CHARACTER (1)
I need to insert into table2 col2 the values of table1 col1 where the value will be mapped from '0' to 'N' and '1' to 'Y'.
This is my current solution:
INSERT INTO table2 (col2)
SELECT col1
FROM table1;
Then, do the update accordingly:
UPDATE table2 set col2 = 'N' where col2 = '0';
UPDATE table2 set col2 = 'Y' where col2 = '1';
I am looking for some condition check, such as '0'?'N':'Y', without writing Stored Procedure. Is there a better way doing this.
Values in col1 table1 = '0', '1'.
Values in col2 table2 = 'N', 'Y'.
Both column types = CHARACTER (1)
I need to insert into table2 col2 the values of table1 col1 where the value will be mapped from '0' to 'N' and '1' to 'Y'.
This is my current solution:
INSERT INTO table2 (col2)
SELECT col1
FROM table1;
Then, do the update accordingly:
UPDATE table2 set col2 = 'N' where col2 = '0';
UPDATE table2 set col2 = 'Y' where col2 = '1';
I am looking for some condition check, such as '0'?'N':'Y', without writing Stored Procedure. Is there a better way doing this.
0