Search or Filter Column Name in MySQL

When we have a big database with too much column, its hard to find some column when we need it to create query or just to identifying the table. Even we just DESC table query, its nont enough because still to hard to find what we need if we have too much table.

Then, how to filter or search mysql column with spesifiq keyword or just like “like” on mysql query. The solution is using information schema.

Here is my final query to do this.

SELECT
  `COLUMN_NAME`
FROM
  `INFORMATION_SCHEMA`.`COLUMNS`
WHERE `TABLE_SCHEMA` = 'database_name'
  AND `TABLE_NAME` = 'table_name'
  AND COLUMN_NAME LIKE '%filter_key%';

there is 3 paramter that you should change, there is database_name, table_name and filter_key. Because its a query in MySQL, so you can modify this query as you need it. Cheers!



0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments

0
Would love your thoughts, please comment.x
()
x