How can I use a query such as this SELECT * FROM * WHERE % = 'name'
to scan through all the tables in my database for name
?
Asked
Active
Viewed 1,932 times
1 Answers
0
your select statement is missing a column. so maybe like SELECT * FROM * WHERE $col = '%name';
the quick and dirty answer outside php (say bash) is to
- step one find the tables in the db. tables=
mysql -uuser -psecret MYDB -B -e 'show tables'|sed -e '2,$p'
- step 2; iterate over tables with your select statement replacing FROM * with for loop using $tables var.
-
- step 2.5 as you iterate collect your results in a variable as an array or map.
- step 3; examine that map.
this all said unless the $col is common across all tables, this question does not make sense.

Rob
- 214
- 1
- 5