79631473

Date: 2025-05-21 07:40:00
Score: 0.5
Natty:
Report link

Maybe you could write a dynamic script?

Or I just came up with this -

-- Step 1: Set group_concat limit
SET SESSION group_concat_max_len = 1000000;

-- Step 2: Generate full UNION query
SELECT GROUP_CONCAT(
    CONCAT(
        'SELECT ''', table_name, ''' AS table_name, ',
        'MIN(created_at) AS min_created_at, ',
        'MAX(created_at) AS max_created_at FROM `', table_schema, '`.`', table_name, '`'
    )
SEPARATOR ' UNION ALL ')
INTO @sql
FROM information_schema.columns
WHERE table_schema = 'my_schema'
  AND column_name = 'created_at'
  AND data_type IN ('timestamp', 'datetime');

-- Step 3: Prepare and execute it
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

Just check once whether it is what you need. ;>

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: cuder