-- ============================================
-- 修复学员状态为NULL的记录
-- ============================================
-- 将所有学员的student_status为NULL的记录设置为默认值'incarcerated'（在押）

UPDATE sys_user 
SET student_status = 'incarcerated'
WHERE del_flag = '0'
  AND (remark LIKE '%注册类型:student%' OR remark LIKE '%注册类型:学员%')
  AND (student_status IS NULL OR student_status = '');

-- 查询更新后的结果
SELECT 
  user_id AS '信息编号',
  user_name AS '账号',
  nick_name AS '罪犯姓名',
  student_status AS '学员状态',
  remark AS '备注'
FROM sys_user 
WHERE del_flag = '0'
  AND (remark LIKE '%注册类型:student%' OR remark LIKE '%注册类型:学员%')
ORDER BY user_id;

