2014-03-27 74 views
-1

我的查詢一次更新兩個不同的表。我想知道我怎麼會做這個工作更新查詢我在MySQL新的,所以我不知道該怎麼辦謝謝我如何使這是一個工作更新MySQL中的查詢

這裏是我的查詢

$sSQLupdate = "UPDATE settings SET companyName = '$companyname', 
              companyAddress = '$companyaddress', 
              companyContact = '$companycontact', 
              excessot1 = '$excessot1', 
              multiplierOT1 = '$multiplier1', 
              excessot2 = '$excessot2', 
              multiplierOT2 = '$multiplier2', 
              ndRangeFrom = '$ND_in', 
              ndRangeTo = '$ND_out', 
              multiplierNd = '$NDmul' 
              WHERE id = 1"; 


"UPDATE holidaytype SET multiplier = '$regularmul' WHERE type = 'Regular'"; 
"UPDATE holidaytype SET multiplier = '$specialrmul' WHERE type = 'Special'"; 
"UPDATE holidaytype SET multiplier = '$doubleregularmul' WHERE type = 'DRegular'"; 
"UPDATE holidaytype SET multiplier = '$doublespecialmul' WHERE type = 'DSpecial'"; 

的PHP代碼是這裏,我只是如何從輸入文本框獲取值:

  $companyname = $this->input->get('companyname'); 
     $companyaddress = $this->input->get('companyaddress'); 
     $companycontact = $this->input->get('companycontact'); 
     $excessot1 = $this->input->get('excessot1'); 
     $multiplier1 = $this->input->get('multiplier1'); 
     $excessot2 = $this->input->get('excessot2'); 
     $multiplier2 = $this->input->get('multiplier2'); 
     $ND_in = $this->input->get('NDfrom'); 
     $ND_out = $this->input->get('NDto'); 
     $NDmul = $this->input->get('NDmul'); 
     $regularmul = $this->input->get('regularmulti'); 
     $specialmul = $this->input->get('specialmulti'); 
     $doubleregularmul = $this->input->get('doubleregmulti'); 
     $doublespecialmul = $this->input->get('doublespecialmul'); 
     $restdaymul1 = $this->input->get('restmul1'); 
     $restdaymul2 = $this->input->get('restmul2'); 
     $restdaymul3 = $this->input->get('restmul3'); 
     $restdaymul4 = $this->input->get('restmul4'); 
+0

看來你正在使用PHP。你也可以使用這些變量和sql語句發佈你的代碼嗎? –

+0

@Ravinder:更新了我的文章 – user3404341

+1

@ user340341:您在執行sql語句時編寫的代碼。你碰到哪一部分SQL語句?你期待什麼改變? –

回答

0
$sSQLupdate = "UPDATE settings SET companyName = '" . $companyname . "', 
            companyAddress = '" . $companyaddress . "', 
            companyContact = '" . $companycontact . "', 
            excessot1 = '" . $excessot1 . "', 
            multiplierOT1 = '" . $multiplier1 . "', 
            excessot2 = '" . $excessot2 . "', 
            multiplierOT2 = '" . $multiplier2 . "', 
            ndRangeFrom = '" . $ND_in . "', 
            ndRangeTo = '" . $ND_out . "', 
            multiplierNd = '" . $NDmul . "' 
            WHERE id = 1";