SQL Help
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: SQL Help

  1. #1
    Join Date
    Nov 2000
    Location
    Atlanta, GA, USA
    Posts
    85
    Table1
    acct date
    ==================
    111 01-jan-01
    112 08-feb-00
    113 18-mar-01
    114 17-jun-00
    115 21-jul-00
    116 30-apr-00

    Table2
    acct status date1
    =====================
    111 open ?
    112 cls ?
    113 tbd ?
    114 tbd ?
    115 cls ?
    116 open ?

    Can someone please help me write a sql query to do the following:
    I need to copy the values of table1, date column to table2, date1 column. The two tables can be linked by column acct. Both tables have
    many other columns that are not listed here.
    Thanks for your help.

  2. #2
    Join Date
    Feb 2001
    Posts
    15
    Are you trying to insert date from table1 to table2(date1)?
    If yes, then

    insert into table table2
    (date1)
    select a.date from table1 a , table2 b where
    a.acct =b.acct ;


  3. #3
    Join Date
    Feb 2001
    Posts
    180
    Maybe this will help you out:
    declare
    cursor c_t1
    is
    select * from table1;

    begin
    for vc_t1 in c_t1
    loop
    update table2
    set date1 = vc_t1.date
    where acct = vc_t1.acct;
    end loop;
    commit;
    end;
    /
    Regards
    Ben de Boer

  4. #4
    Join Date
    Feb 2001
    Posts
    15

    just corrected


    insert into table2
    (date1)
    select a.date from table1 a , table2 b where
    a.acct =b.acct ;




  5. #5
    Join Date
    Nov 2000
    Location
    Atlanta, GA, USA
    Posts
    85
    Thank you very much for all your help !

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