0

I am having an issue for formulating this question, but this is essentially what I want. Once connecting to a database I want to search for something which could be in any table inside any column.

SELECT * FROM table1 where column='123456789'

becomes

SELECT * FROM [AllTablesInDatabase] where [AllColumnsInDatabase]='%123456789%'

I feel like this is a common question, but I can't seem to formulate it in a way that I can find the answer to this. I am using mySQL, 8.0 I believe, just trying to see what I can do in it. I can see that I likely can just output a list of a huge database's tables and columns and just paste it, but that is going to be an extremely long statement.

Lukali
  • 343
  • 1
  • 4
  • 15
  • Or this? https://stackoverflow.com/questions/639531/search-text-in-fields-in-every-table-of-a-mysql-database – Nico Haase Jan 18 '22 at 14:28
  • A database typically stores each table in one or more files. So when you say search all tables/files, you're in effect searching all data files related to the database. So you will likely need to iterate though all tables to search all files. such a task will not be performant. The method would be a stored procedure which uses the system tables to iterate though the list of tables/fields and executes a query looking at each for the desired value. Now you don't define the expected results so are you after the table/field key which contains the result? – xQbert Jan 18 '22 at 14:47

0 Answers0