user304479
user304479

Reputation: 41

Searching in several mysql tables

There is a MySQL database with several(but we don't know how much) tables. The only thing I know about them, is that all of them have a prefix 'pref'. So how can I search in every table, if a don't know their names ? Can you help me with the query ?

Sorry for my bad english

Upvotes: 1

Views: 65

Answers (2)

kailash19
kailash19

Reputation: 1821

Do you want to take out all the tables names starting with prefix 'pref'. If YEs, you can run following query:

SELECT table_name FROM information_schema.tables WHERE table_name LIKE 'pref%'

Upvotes: 1

Abhijit Buchake
Abhijit Buchake

Reputation: 142

You can query information_schema.tables to know all the tables starting with 'pref' and query them individually. Use a stored procedure if this is a frequent task.

Upvotes: 0

Related Questions