ETest-Vue-FastAPI/check_orders_issue.sql

52 lines
962 B
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

-- 检查订单数据问题
-- 1. 查看最近创建的订单包括可能被INNER JOIN过滤掉的
SELECT
id,
name,
creator,
create_time,
update_by,
update_time,
state,
total_count,
complate_count
FROM test_order
ORDER BY id DESC
LIMIT 20;
-- 2. 检查是否有订单的creator不在sys_user表中
SELECT
o.id,
o.name,
o.creator,
u.user_id,
u.nick_name
FROM test_order o
LEFT JOIN sys_user u ON o.creator = u.user_id
WHERE u.user_id IS NULL
ORDER BY o.id DESC;
-- 3. 检查是否有订单的update_by不在sys_user表中
SELECT
o.id,
o.name,
o.update_by,
u.user_id,
u.nick_name
FROM test_order o
LEFT JOIN sys_user u ON o.update_by = u.user_id
WHERE u.user_id IS NULL
ORDER BY o.id DESC;
-- 4. 查看工单关联的订单ID
SELECT
id,
name,
test_order_id,
order_id,
create_time
FROM test_work_order
WHERE order_id IS NOT NULL
ORDER BY id DESC
LIMIT 20;