DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: update table

  1. #1
    Join Date
    Jul 2002
    Posts
    228

    update table

    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

  2. #2
    Join Date
    Jul 2002
    Location
    Lake Worth, FL
    Posts
    1,492
    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);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width