Reputation: 41
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
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
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