4
I need to sample all tables in a Mysql database, for example through a SELECT * ... LIMIT 10
.
I already have the code that returns all tables of the current database:
select table_name from information_schema.tables where table_schema = database();
The following (incorrect) query illustrates what I wish to do:
Select * from (
select table_name from information_schema.tables where table_schema = database()
) limit 10;
, which would function as:
Select * from tabela1 limit 10;
Select * from tabela2 limit 10;
...
Select * from tabelaN limit 10;
How can I do this in a single query?
I found examples that speak of cursors, but I’m not sure how I could apply them in this case.
I saw a very similar example in SQL Server using cursors, but I couldn’t adapt it to Mysql.
I’m not sure, but I think with only one Procedure or Function.
– gabrielhof
I think you can do with a common select yes.
– gmsantos