Updating a table with data from other table
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: Updating a table with data from other table

  1. #1
    Join Date
    Oct 2007
    Posts
    2

    Updating a table with data from other table

    I apologize if my question sounds too basic...

    I have two tables as described below:

    tblONE
    ----------
    ID Number(9,0) not null - Primary key
    Holding Char(250)

    tblTWO
    ----------
    ID Number(9,0) not null - Repeatable
    Holdind Char(30)

    Data examples of tblONE (see that Holding fields are empty)
    ------------------------------------
    ID Holding
    001
    002
    003
    004
    005

    Data examples of tblTWO
    ------------------------------------
    ID Holding
    001 v.1, n.1, 1989
    002 v.22, n.13, 1990
    002 v.23, n.14, 1991
    003 v.56, n. 2, 2002
    004 v.87, n. 20, 2001
    004 v.54, n. 3, 2006
    004 v.55, n. 4, 2007
    005 v.3, n. 5, 1998

    What I want is updating HOLDING field of tblONE with the content of HOLDING field from tblTWO, like that:
    (see that ID field is UNIQUE in tblONE and it can occours more than once in tblTWO)

    NEW Data examples of tblONE
    --------------------------------------------
    ID Holding
    001 v.1, n.1, 1989
    002 v.22, n.13, 1990 -- v.23, n.14, 1991
    003 v.56, n. 2, 2002
    004 v.87, n. 20, 2001 -- v.54, n. 3, 2006 -- v.55, n. 4, 2007
    005 v.3, n. 5, 1998


    TIA,

    Bill
    Last edited by bl4tech; 10-18-2007 at 03:36 AM.

  2. #2
    Join Date
    Oct 2007
    Posts
    7

    Junior Member

    You can try out following and see whether it satisfies your requirement or not :

    update tblONE a
    set Holdind=(select holdind from tblTWO
    where
    ID=a.ID
    and rownum=1)

  3. #3
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,554
    Neat definition but you forgot both to show your best effort and to ask your question.
    Show us your best try and somebody will point you in the right direction if needed.
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

  4. #4
    Join Date
    Oct 2007
    Posts
    2
    Quote Originally Posted by PAVB
    Neat definition but you forgot both to show your best effort and to ask your question.
    Show us your best try and somebody will point you in the right direction if needed.

    As a matter of fact, I do not know how to do that! That's why I post this question.

    BL4TECH

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