diff --git a/help/脏数据查询.sql b/help/脏数据查询.sql new file mode 100644 index 000000000..3a9ed8721 --- /dev/null +++ b/help/脏数据查询.sql @@ -0,0 +1,11 @@ +SELECT * + +FROM pet +WHERE + -- 核心条件:两个CatchTime值不相等,或data中无CatchTime字段 + ( + -- 1. 类型统一后对比(catch_time和data->CatchTime都转int4) + (data->>'CatchTime')::int4 != catch_time::int4 + -- 2. data中没有CatchTime字段(也需要筛选) + OR NOT jsonb_exists(data, 'CatchTime') + ); \ No newline at end of file