peixue-dev/Archive/[一次性]检查supplement字段数据.sql

42 lines
955 B
SQL

-- 检查 growth_record 表中是否有 supplement 字段的数据
-- 1. 查看表结构,确认 supplement 字段是否存在
DESCRIBE growth_record;
-- 2. 查询最近更新的记录,查看 supplement 字段的值
SELECT
id,
order_id,
teacher_id,
student_name,
record_date,
record_type,
content,
supplement,
create_time,
update_time
FROM growth_record
ORDER BY update_time DESC
LIMIT 10;
-- 3. 查询有 supplement 内容的记录
SELECT
id,
order_id,
student_name,
record_date,
record_type,
supplement,
update_time
FROM growth_record
WHERE supplement IS NOT NULL
AND supplement != ''
ORDER BY update_time DESC;
-- 4. 统计有多少条记录有 supplement 内容
SELECT
COUNT(*) as total_records,
COUNT(supplement) as records_with_supplement,
COUNT(CASE WHEN supplement IS NOT NULL AND supplement != '' THEN 1 END) as records_with_content
FROM growth_record;