2014-12-26 90 views
0

我寫查詢更新兩個表內加盟加盟:更新查詢在PHP

function update($student_id,$data){ 
    $email=$data['Email']; 
    $firstname=$data['FirstName']; 

    $sql= "update users u 
    INNER JOIN students s ON u.id= s.user_id 
    SET u.Email='$email', 
     s.Email='$email', 
     u.FirstName='$firstname' 
    WHERE s.id='$student_id'"; 
    $result = $this->db->query($sql); 
     return $result; 
} 

以及我米沒有得到任何錯誤,但我不是能夠在更新數據庫中的表。

+0

哪裏是$ SQL?回聲您的查詢,並通過運行phpmyadmin –

+0

@Rakesh夏爾馬哦,這是寫在這裏SO – webpic

+0

回聲$ sql;並運行在phpmyadmin獲得任何行影響? –

回答

0

試試這個..

UPDATE u  
    SET u.Email='$email', 
     s.Email='$email', 
     u.FirstName='$firstname' 
from users u INNER JOIN students ON s u.id= s.user_id WHERE s.id='$student_id'