Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2010

    Unanswered: Updating one table after insert in another table

    I have been having a hard time figuring out how to make 'table2' update its values based on the values in 'table1' whenever new rows are inserted in 'table1'. I insert a couple thousand rows into 'table1' at a time using 'load data infile' and text files. If possible I would like the update on table 2 to occur after the entire file is inserted in to 'table1', not after each row is inserted. Any help would be greatly appreciated. Below I have included the definition from table1 and what I need in table2.

    create table table1 (
    V1 varchar(5),
    V2 varchar(5),
    V3 date,
    V4 double,
    V5 date,
    V6 double,
    V7 double,
    Primary Key (V1,V2,V3,V4,V5) );

    V1 - Same as table1
    V2 - Same as table1
    V3 - Same as table1
    V4 - Same as table1
    V5 date - minimum of V5 in table1
    V6 date - maximum of V5 in table1

  2. #2
    Join Date
    Apr 2005
    update table2
    set link=
    from table2 t2
    join table1 t1
    on =

    Web Database Software - Build your own php mysql database.

  3. #3
    Join Date
    Apr 2002
    Toronto, Canada
    sonic, i think you will find that your microsoft sql server UPDATE syntax (specifically, the FROM construction) will not work in mysql | @rudydotca
    Buy my SitePoint book: Simply SQL

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