How to multiple UPDATE statement in one query?

Discussion in 'PHP' started by KingCobra, Oct 4, 2012.

  1. #1
    My query ($query3) giving error because I engaged 3 update statement in a query. It said "Characters found after end of SQL statement" or not constructed properly. I tested following 3 ways. but no wone working. If i use just 1 upade statement the it works fine. Please help me and tell me how can I make it work.


    
    $conn = odbc_connect('Driver={Microsoft Access Driver (*.mdb)}; DBQ=E:\x.mdb','','');
    
    
    $query3  = "UPDATE daily_index SET cscx_show = '$show_value', cscx_value = '$cscx_value' WHERE cscx_name = 'value';";
    $query3 .= "UPDATE daily_index SET cscx_show = '$show_change', cscx_value = '$cscx_change' WHERE cscx_name = 'change';";
    $query3 .= "UPDATE daily_index SET cscx_show = '$show_unchanged', cscx_value = '$cscx_percent_change' WHERE cscx_name = 'percent_change'";
    
    //----------------------------------
    
    $query3  = "UPDATE daily_index SET cscx_show = '$show_value', cscx_value = '$cscx_value' WHERE cscx_name = 'value';
    UPDATE daily_index SET cscx_show = '$show_change', cscx_value = '$cscx_change' WHERE cscx_name = 'change';
    UPDATE daily_index SET cscx_show = '$show_unchanged', cscx_value = '$cscx_percent_change' WHERE cscx_name = 'percent_change'";
    
    //-----------------------------------
    
    $query3 = "UPDATE daily_index SET 
             (cscx_show = '$show_value', cscx_value = '$cscx_value' WHERE cscx_name = 'value'),
             (cscx_show = '$show_change', cscx_value = '$cscx_change' WHERE cscx_name = 'change'),
             (cscx_show = '$show_unchanged', cscx_value = '$cscx_percent_change' WHERE cscx_name = 'percent_change')";
    
    
    odbc_exec($conn, $query3) or die ("Error in update query 3. ");  
    
    PHP:

     
    KingCobra, Oct 4, 2012 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
  3. Vick.Kumar

    Vick.Kumar Active Member

    Messages:
    138
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    90