Quote:
Originally posted by raf
hi
I've a table A
ID NUM NAME IP
1 10 TOM 500
2 20 SAM 510
3 30 TOM 630
4 40 SAM 800
This table has more 1000 same records
I'd like insert into A same records change just the name:
ID NUM NAME IP
1 10 TOM 500
1 10 SAM 500
2 20 SAM 510
2 20 TOM 510
3 30 TOM 630
3 30 SAM 630
4 40 SAM 800
4 40 TOM 800
How can I create a script for this??
Thanks
Raf
|
Are there just those 2 names TOM and SAM? If so, you can use a DECODE or CASE:
INSERT INTO a
SELECT id, num, DECODE(name.'TOM','SAM','TOM'), ip
FROM a;
INSERT INTO a
SELECT id, num, CASE WHEN name = 'TOM' THEN 'SAM' ELSE 'TOM' END, ip
FROM a;