57 lines
1.1 KiB
MySQL
57 lines
1.1 KiB
MySQL
|
|
-- 检查成长记录数据的详细信息
|
|||
|
|
SELECT
|
|||
|
|
id,
|
|||
|
|
student_id,
|
|||
|
|
student_name,
|
|||
|
|
record_type,
|
|||
|
|
record_date,
|
|||
|
|
status, -- ✅ 检查status字段
|
|||
|
|
is_archived, -- ✅ 检查是否归档
|
|||
|
|
LEFT(content, 30) as content_preview,
|
|||
|
|
create_time
|
|||
|
|
FROM growth_record
|
|||
|
|
WHERE student_id = 1
|
|||
|
|
ORDER BY record_date DESC;
|
|||
|
|
|
|||
|
|
-- 检查status字段的值分布
|
|||
|
|
SELECT
|
|||
|
|
status,
|
|||
|
|
COUNT(*) as count
|
|||
|
|
FROM growth_record
|
|||
|
|
WHERE student_id = 1
|
|||
|
|
GROUP BY status;
|
|||
|
|
|
|||
|
|
-- 检查是否有status=1的记录
|
|||
|
|
SELECT COUNT(*) as count
|
|||
|
|
FROM growth_record
|
|||
|
|
WHERE student_id = 1
|
|||
|
|
AND status = 1;
|
|||
|
|
|
|||
|
|
-- 检查是否有record_type='daily'且status=1的记录
|
|||
|
|
SELECT COUNT(*) as count
|
|||
|
|
FROM growth_record
|
|||
|
|
WHERE student_id = 1
|
|||
|
|
AND record_type = 'daily'
|
|||
|
|
AND status = 1;
|
|||
|
|
|
|||
|
|
-- 如果status不是1,更新为1
|
|||
|
|
UPDATE growth_record
|
|||
|
|
SET status = 1
|
|||
|
|
WHERE student_id = 1
|
|||
|
|
AND (status IS NULL OR status != 1);
|
|||
|
|
|
|||
|
|
-- 验证更新后的数据
|
|||
|
|
SELECT
|
|||
|
|
id,
|
|||
|
|
student_id,
|
|||
|
|
student_name,
|
|||
|
|
record_type,
|
|||
|
|
record_date,
|
|||
|
|
status,
|
|||
|
|
LEFT(content, 30) as content_preview
|
|||
|
|
FROM growth_record
|
|||
|
|
WHERE student_id = 1
|
|||
|
|
AND record_type = 'daily'
|
|||
|
|
AND status = 1
|
|||
|
|
ORDER BY record_date DESC;
|