You could generate the SQL query by scanning the catalog, e.g.:
Code:
SELECT table_name
FROM information_schema.tables
WHERE table_name like '<your-prefix>%'
and then build the above query programmatically. With a bit of recursive SQL you can build the whole query in a single SQL statement, fetch that result and execute it dynamically as another query.
p.s: The ISO standard defines the catalog tables in a schema named INFORMATION_SCHEMA. Most systems use other schema names and may also have other table/column names.