UPDATE 表名 SET 列名=新值 WHERE 條件;
示例:
UPDATE student SET name='張三' WHERE id=1;
UPDATE 表名 SET 列名1=新值1, 列名2=新值2, ... WHERE 條件;
示例:
UPDATE student SET name='張三', age=20 WHERE id=1;
UPDATE 表名 SET 列名=新值;
示例:
UPDATE student SET age=20;
UPDATE 表名 SET 列名=子查詢 WHERE 條件;
示例:
UPDATE student SET age=(SELECT AVG(age) FROM student) WHERE id=1;
UPDATE 表1 JOIN 表2 ON 條件 SET 表1.列名=新值;
示例:
UPDATE student JOIN score ON student.id=score.student_id SET student.age=20 WHERE score.score>80;