202502-Wms-NanTongYaChi/fix_vehicle_data.sql
2025-07-18 13:24:53 +08:00

39 lines
864 B
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.

-- 修正 t_app_wcs_task_bak 表中 vehicle_id 字段的异常数据
USE wms_yachi_nantong;
-- 1. 查看异常数据
SELECT
wcs_task_id,
vehicle_id,
create_time
FROM t_app_wcs_task_bak
WHERE vehicle_id LIKE 'FC%'
OR vehicle_id LIKE '%/%'
OR vehicle_id LIKE '%:%'
ORDER BY create_time DESC
LIMIT 10;
-- 2. 统计异常数据数量
SELECT
COUNT(*) as total_abnormal_records
FROM t_app_wcs_task_bak
WHERE vehicle_id LIKE 'FC%'
OR vehicle_id LIKE '%/%'
OR vehicle_id LIKE '%:%';
-- 3. 修正异常数据设置为NULL
UPDATE t_app_wcs_task_bak
SET vehicle_id = NULL
WHERE vehicle_id LIKE 'FC%'
OR vehicle_id LIKE '%/%'
OR vehicle_id LIKE '%:%';
-- 4. 验证修正结果
SELECT
wcs_task_id,
vehicle_id,
create_time
FROM t_app_wcs_task_bak
WHERE vehicle_id IS NOT NULL
ORDER BY create_time DESC
LIMIT 10;