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;