multiple update similiar to multiple insert??

Discussion in 'MySQL' started by vetrivel, Sep 9, 2009.

  1. #1
    Hi,
    Is there any possible to multiple update in the single query similiar to insert query.

    ex:
    insert into table (fields) values(value1,value2,etc).

    This query is really time saving compared to one by one insert.


    Since i am going to do it for around 15,000 records.

    I need similiar query to the update as well.
    Is it possible ???

    say for example;
    update table set (fieldnames ) values(value1,value2,etc).
     
    vetrivel, Sep 9, 2009 IP
  2. ramu.ds

    ramu.ds Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    possible Mr.vetrivel. using arrays u r problem is slow.
     
    ramu.ds, Sep 9, 2009 IP
  3. ramu.ds

    ramu.ds Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    foreach($_POST['join'] as $key => $val)
    {
    $keysAry[] = $key;
    $valsAry[] = "'".$val."'";
    }
    $keysAry[] = 'uploadfile';
    $valsAry[] = "'".$filename."'";

    $keysAry[] = 'regdate';
    $valsAry[] = "'".date('Y-m-d')."'";

    $keysAry[] = 'status';
    $valsAry[] = '1';

    $keys = implode("," ,$keysAry);
    $vals = implode("," , $valsAry);

    $qry = "insert into joinsus_details (".$keys.") values (".$vals.")";
    $sql = mysql_query($qry);
    in this program names are complsary database name u matain like name="araauname[databasename]"
     
    ramu.ds, Sep 9, 2009 IP
  4. vetrivel

    vetrivel Peon

    Messages:
    147
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi ,
    I need it for the update query and not for the insert .
    And
    am trying to concat all the update query into a variable using the semicolon and update it with the help of foreach.
    It is working .But my concern is speed, and time taken .



     
    vetrivel, Sep 10, 2009 IP
  5. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #5
    It is not possible if you have different values and different WHERE conditions for each combination.
     
    mwasif, Sep 10, 2009 IP