fix biblionumber
[google-map-tiles.git] / koha-import.pl
index 21ba1b4..b2ba4d1 100755 (executable)
@@ -142,7 +142,7 @@ create table geo_city (
 my $sth_insert = $g_dbh->prepare(qq{insert into geo_city values (?,?,?,?,?,?,?,?)});
 
 my $sth = $g_dbh->prepare(qq{
-select count(*),city from geo_biblioitems group by city order by count(city) desc
+select count(*),city from geo_biblioitems where city not in (select city_koha from geo_city) group by city order by count(city) desc
 });
 $sth->execute;
 
@@ -166,3 +166,21 @@ while( my $row = $sth->fetchrow_hashref ) {
                , dump($location)
        );
 }
+
+eval { $g_dbh->do(qq{ drop table geo_count }) };
+$g_dbh->do(qq{
+
+select
+       count(biblionumber)
+       ,point(lat,lng)
+       ,geo_city.city
+       ,geo_city.city_koha
+       ,country
+into geo_count
+from geo_biblioitems
+join geo_city on city_koha = geo_biblioitems.city
+where length(geo_city.city) > 1
+group by geo_city.city, country, lat, lng, city_koha
+order by count(biblionumber) desc
+
+});