Results 1 to 4 of 4
  1. #1
    Join Date
    May 2003
    Location
    Pinoy in NJ
    Posts
    104

    Unanswered: How to update table values from another table?

    I have 2 tables (pls. see below). How can I update Table B with the PAYABLE value from table A with the EmployeeID as reference using SQL?

    Thanks.


    TABLE A
    ------------------------------
    | EmployeeID | PAYABLE |
    ------------------------------
    | 10001 | 1 |
    | 10002 | 1 |
    ------------------------------

    TABLE B
    -----------------------------------------
    | Store # | EmployeeID | PAYABLE |
    -----------------------------------------
    | 1021 | 10001 | null |
    | 1245 | 10001 | null |
    | 1456 | 10002 | null |
    -----------------------------------------

  2. #2
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621
    Try this one

    update tableB set payable=tableA.payable
    from tableA where tableA.EmployeeID=tableB.EmployeeID

  3. #3
    Join Date
    Jan 2003
    Location
    India
    Posts
    523

    Re: How to update table values from another table?

    Originally posted by ARPRINCE
    I have 2 tables (pls. see below). How can I update Table B with the PAYABLE value from table A with the EmployeeID as reference using SQL?

    Thanks.


    TABLE A
    ------------------------------
    | EmployeeID | PAYABLE |
    ------------------------------
    | 10001 | 1 |
    | 10002 | 1 |
    ------------------------------

    TABLE B
    -----------------------------------------
    | Store # | EmployeeID | PAYABLE |
    -----------------------------------------
    | 1021 | 10001 | null |
    | 1245 | 10001 | null |
    | 1456 | 10002 | null |
    -----------------------------------------



    update B set payable =A.payable from A where A.empid=B.empid

  4. #4
    Join Date
    May 2003
    Location
    Pinoy in NJ
    Posts
    104

    Thumbs up

    Thank you both for your inputs. It did the trick!

Posting Permissions

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