Where the heck is that stored?
This script will find all tables that have a column that has the name of the first argument. If there is a second argument it will query the tables how many times the value exists in the column of the various tables. I imagine sooner or later I will improve the ability to quote…
#!/bin/bash
my="mysql -u YOURUSERNAME -pYOURPASSWORD -e"
if [ -p $1 ]; then
echo "usage: find.sh field (value)"
exit;
fi
for i in $($my "SELECT CONCAT(TABLE_SCHEMA,'.',TABLE_NAME) AS ''
FROM information_schema.COLUMNS
WHERE column_name='$1';"); do
if [ -p $2 ]; then
echo $i
else
query="SELECT COUNT(*) AS ''
FROM $i
WHERE $1=$2;"
echo $i $($my "$query")
fi
done