Keboola WIKI‎ > ‎Transformations‎ > ‎MySQL‎ > ‎

Query that takes all whats in input mapping and unions it all

by tomas.trnka@keboola.com
---
This query takes all tables from the input mapping that are from the same input bucket (note the "...LIKE '%in.c-data_od_klientu.%'...") and creates table `out` by UNION ALL

enjoy!

SET SESSION group_concat_max_len = 1000000;

SELECT
CONCAT('CREATE TABLE `out` AS ',GROUP_CONCAT('
SELECT * FROM `',`TABLE_NAME`,'`
' SEPARATOR 'UNION ALL'),';')
INTO @query
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME LIKE '%in.c-data_od_klientu.%' ;

PREPARE temp_query FROM @query;

EXECUTE temp_query;
Comments