删除数据库中重复字段且特定列为空的行
在数据库中删除重复字段且特定列为空的行,可使用以下查询语句:
DELETE FROM datas WHERE pid IS NULL AND (credit, company, name, phone, id) IN ( SELECT credit, company, name, phone, id FROM datas WHERE pid IS NOT NULL );
查询说明:
删除过程:
这样做可以删除具有相同重复字段组合但 pid 为 null 的行,同时保留具有相同重复字段组合但 pid 不为 null 的行。