#!/usr/bin/perl use PApp::SQL; local $PApp::SQL::DBH = PApp::SQL::connect_cached "dinfo::", "DBI:mysql:dinfo"; for my $col (qw( name vorname zusatz1 zusatz2 zusatz3 vorwahl strasse haus plz ort branche )) { my ($id, $count) = sql_fetch "select $col, count(*) from row group by 1 order by 2 desc limit 1"; warn "$col => ($id) * $count\n"; next unless $id; sql_exec "update $col set id = 0 where id = ?", $id; sql_exec "update row set $col = 0 where $col = ?", $id; }