我已经编写了用内部联接更新两个表的查询:
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 :(得分: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'