插入或更新学生信息的 SQL 语句

#! https://zhuanlan.zhihu.com/p/667794849
插入或更新学生信息的 SQL 语句

INSERT INTO student_info_table (
    id, 
    name, 
    age, 
    gender, 
    major, 
    grade, 
    attendance_state, 
    last_attendance_time
) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE
    name = VALUES(name),
    age = VALUES(age),
    gender = VALUES(gender),
    major = VALUES(major),
    grade = VALUES(grade),
    attendance_state = VALUES(attendance_state),
    last_attendance_time = VALUES(last_attendance_time);

这里假设有一个名为 student_info_table 的表,包含了学生的信息,其中 id 是主键或者唯一键。你需要根据实际的数据库表结构进行适当的修改,确保列名和数据类型等匹配。在这个例子中,我们插入或更新了学生的 ID、姓名、年龄、性别、专业、年级、考勤状态和最后考勤时间等信息。

你可能感兴趣的:(sql,数据库)