I want to search a single string or word from MYSQL database that contains more than 50 table.I do not know what is the column or table where this string may be located.is there any command or function that return table and column name that contain the desired string.please help
Asked
Active
Viewed 459 times
0
-
Maybe export the whole lot (i.e. do an ordinary backup) and then search the output via e.g. Windows find? – MandyShaw Feb 02 '19 at 18:26
-
1Possible duplicate of [Search in all fields from every table of a MySQL database](https://stackoverflow.com/questions/639531/search-in-all-fields-from-every-table-of-a-mysql-database) – Matthew Page Feb 02 '19 at 18:44
1 Answers
1
You can get a list of all the tables and the columns available in a database using the below query.
SELECT * FROM INFORMATION_SCHEMA.COLUMNS;
Using the values get from TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, you can get the matched table name and column name using the below query.
SELECT * FROM table_name WHERE column_name LIKE "%your_string%";

Valerian Pereira
- 725
- 1
- 6
- 16

Sowmya Shankark
- 71
- 3