Click to See Complete Forum and Search --> : update table


raf
05-08-2003, 09:14 AM
I've 2 tables
table cod with more 4000 records:

code
axyz-0-12345678
axfr-0-23456789
asdf-0-22323232
aa3r-0-11111122
..............
..............
and table code_id with 250 records that are also in table cod

id
axyz-0-12345678
axfr-0-23456789
...............

Can I update table cod with these new codes??

code
axyz-Z-12345678
axfr-Z-23456789

if cod.code=code_id.id then xxxx-Z-xxxxxxxx

Coul you help me??
Thanks
Raf

LKBrwn_DBA
05-08-2003, 10:35 AM
Did you try this?:

update code u
set code_id = (
select replace(code_id,'-0-','-Z-')
from cod
where cod.code_id = u.code_id)
where exists (
select '?'
from cod
where cod.code_id = u.code_id);
:D