Mysql – How to locate all the tables that have a field named username

information-schemaMySQL

Is there a way in PhpMyAdmin to do a SQL search for all tables, that have a fieldname username in it?

I am trying to help a friend that has a database with over 1,000 tables in it.

He needs to find all of them that have username as a field name, so he can find the list of tables and not have to manually look at each table.

I don't know MySQL enough to do it.

Anyone know where to find the way?

Best Answer

I found it...

SELECT table_name, column_name, data_type, ordinal_position 
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE table_schema = 'dbname' AND column_name LIKE '%username%';