Creates a tab delimited output file (/tmp/sample_magic_types.txt) that can be viewed in excel for better readability:
echo "select magic, resource_magic.magic_id, count(*) as cnt from sample_resources inner join resource_magic on sample_resources.magic_id = resource_magic.magic_id group by resource_magic.magic_id order by cnt desc;" | mysql -p mag2_data > /tmp/sample_magic_types.txt