INSERT查询WHERE条件?

时间:2014-04-18 21:44:20

标签: mysql sql insert where

我的代码是

$queryinsert = mysql_query("
        INSERT INTO studentdata (offsiteleft)
        VALUES ($m_offsiteleft)
        WHERE studentid = '$name'
        ") 
    or die("Error querying database (Offsite minutes INSERT query) ".mysql_error());

给我这个错误

Error querying database (Offsite minutes INSERT query) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE studentid = '31'' at line 3

1 个答案:

答案 0 :(得分:0)

UPDATE studentdata
SET offsiteleft = $m_offsiteleft
WHERE studentid = '$name'