zhibo/check_and_fix_records.sql

44 lines
1.5 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- =====================================================
-- 检查并修复"我的记录"数据问题
-- =====================================================
-- 1. 首先找到当前登录用户的真实ID
-- 从截图看用户ID是 24187196但这可能是显示ID需要找到数据库中的真实uid
SELECT uid, id, nickname, phone, avatar
FROM eb_user
WHERE nickname LIKE '%道玄%'
OR uid = 24187196
OR id = 121
OR id = 43
ORDER BY id DESC
LIMIT 10;
-- 2. 检查观看历史表
SELECT '=== eb_view_history 表数据 ===' as info;
SELECT * FROM eb_view_history ORDER BY update_time DESC LIMIT 20;
-- 3. 检查点赞记录表
SELECT '=== eb_live_room_like 表数据 ===' as info;
SELECT * FROM eb_live_room_like ORDER BY create_time DESC LIMIT 20;
-- 4. 检查关注记录表
SELECT '=== eb_follow_record 表数据 ===' as info;
SELECT * FROM eb_follow_record ORDER BY create_time DESC LIMIT 20;
-- 5. 检查收藏表(如果存在)
SELECT '=== 检查收藏相关表 ===' as info;
SHOW TABLES LIKE '%collect%';
SHOW TABLES LIKE '%favorite%';
-- 6. 查看所有用户的活动数据统计
SELECT '=== 各用户活动数据统计 ===' as info;
SELECT
u.uid,
u.nickname,
(SELECT COUNT(*) FROM eb_view_history vh WHERE vh.user_id = u.uid) as ,
(SELECT COUNT(*) FROM eb_live_room_like lrl WHERE lrl.user_id = u.uid) as ,
(SELECT COUNT(*) FROM eb_follow_record fr WHERE fr.follower_id = u.uid) as
FROM eb_user u
WHERE u.uid IN (121, 43, 24187196)
OR u.nickname LIKE '%道玄%';