Apri 1 (
e chiudi 2 )
. Rimuovi l'ultimo:
SELECT CONCAT('changes',year,month) FROM changes
Modifica
la seconda affermazione dovrebbe essere probabilmente
SET @x := SELECT * FROM (@b) as b;
Funziona, ma non sono sicuro che sia quello che vuoi:
SET @b := 'SELECT CONCAT(''changes'',`year`,`month`) FROM whichchanges';
SET @x := 'SELECT * FROM (SELECT CONCAT(''changes'',`year`,`month`) FROM whichchanges) as b';
Prepare stmt FROM @b;
Prepare stmt FROM @x;
Execute stmt;
Modifica2
Se ho capito bene stai cercando quella singola query:
select * from changes
where change_column in (select distinct concat(`year`, `month`) from whichchanges)
Modifica3
select @b := group_concat(concat(' select * from changes', `year`, `month`, ' union ') separator ' ') as w from whichchanges;
set @b := left(@b, length(@b) - 6);
Prepare stmt FROM @b;
Execute stmt;