database

How do I query my MySQL database for a particular column?

If you’re looking to find a particular column name on your MySQL server, you can use a query like the following:

select table_schema, table_name, column_name from information_schema.columns where column_name like ‘my_column_name’;

where my_column_name is the name of the column name you’re looking for.

Ex. To find column names named “email” you can use the query below.

mysql> select table_schema, table_name, column_name from information_schema.columns where column_name like ’email’;

+——————+——————+————-+
| table_schema | table_name | column_name |
+——————+——————+————-+
| staging | blog_comments | email |
| staging | blogs | email |
| production | users | email |
+——————+——————+————-+
3 rows in set (0.80 sec)

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

To Top