Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2014
    Posts
    2

    Unanswered: Update 1 table with another table

    Hi guys,

    I'm stuck in a problem.

    To explain what I have:

    The first table I have a 3 columns.
    phone number, account number, business type

    The second table is also 3 columns
    phone number, account number, business type

    I have transferred all the phone numbers to the other table where they are unique.

    Now I want to update the second table, then the account numbers and business type matches the phone number.

    My code (which I thought worked):

    update t2, t1
    seen t2.accountnumber = t1.accountnumber
    where t2.phone = t1.phone

    Thanks in advance
    Daniel

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Code:
    update t2
    set t2.accountnumber = t1.accountnumber , t2.businesstype = t1.businesstype
    where t2.phone = t1.phone
    however you will loose any preexisting business type and account number. if thats not a problem then it the above should work OK.
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Aug 2014
    Posts
    2
    Quote Originally Posted by healdem View Post
    Code:
    update t2
    set t2.accountnumber = t1.accountnumber , t2.businesstype = t1.businesstype
    where t2.phone = t1.phone
    however you will loose any preexisting business type and account number. if thats not a problem then it the above should work OK.

    Thanks for the response but i've already found a working solution:

    UPDATE t2
    SET accountnumber =
    (SELECT MAX (accountnumber) FROM t1
    WHERE t1.phone= t2.phone)
    WHERE t2.phone IN
    (SELECT phone FROM t1)

Tags for this Thread

Posting Permissions

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