Wednesday, November 4, 2015

MySQL Count Duplicates

#!/usr/bin/env bash
echo "Table to read:"
read table
echo "Column to count and display:"
read col
echo "Threshold number:"
read num
echo "SELECT $col FROM $table GROUP BY $col HAVING count(*) > $num;";

Useage

Table to read: geocodes Column to count and display: ip Threshold number: 2 SELECT ip FROM geocodes GROUP BY ip HAVING count(*) > 2;

No comments: