Union de tables IF EXISTS
Bonjour ,
Je veux réaliser une union sur des tables en construction ( mois_1 à mois_6 ) .
Mois_5 et _6 n'existent pas encore :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| SELECT ROUND( AVG( pulse ) , 2 ) AS 'Moyenne>>Janv:Fevr:Mars:Avri:Mai:Juin'
FROM `mois_1`
UNION
SELECT ROUND( AVG( pulse ) , 2 )
FROM `mois_2`
UNION
SELECT ROUND( AVG( pulse ) , 2 )
FROM `mois_3`
UNION
SELECT ROUND( AVG( pulse ) , 2 )
FROM `mois_4`
IF EXISTS (
UNION
SELECT ROUND( AVG( pulse ) , 2 )
FROM `mois_5`
)
IF EXISTS (
UNION
SELECT ROUND( AVG( pulse ) , 2 )
FROM `mois_6`
) |
Erreur :
Citation:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF EXISTS ( UNION SELECT ROUND( AVG( pulse ) , 2 ) FROM `mois_5` ) IF EXIST' at line 12
Quels conseils pouvez vous me donner ?
:mrgreen:
Version : 5.5.34