voilou, je viens de découvrir les variables PHP et c'est bien pratique
http://dev.mysql.com/doc/refman/5.0/fr/variables.html
http://dev.mysql.com/doc/refman/5.0/...variables.html

le plus fustrant, c'est que ma requete fonctionne parfaitement sous PhpMyAdmin mais je n'arrive pas à la faire fonctionner dans une page php

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$q= "
SET @a=0;
SET @b=0;
SET @c=0;
SELECT date_format(date, '%Y-%M') as Mois, 
date_format(date, '%d') as Jour,  
MSISDN, 
if (count(TRANSACTION_ID) < 2, @a:=@a+1, '') as inf, 
if (count(TRANSACTION_ID) = 2, @b:=@b+1, '') as egal,
if (count(TRANSACTION_ID) > 2, @c:=@c+1, '') as egal,
count(TRANSACTION_ID) as Toute
FROM `INDEX_EUROPE`
GROUP BY Mois, Jour, MSISDN";
 
$t=mysql_query ($q) or die ("<br>erreur de requete ".$q.", <br><br>erreur ".mysql_error());
echo "<pre>";
print_r ($t);
echo "</pre>";

Cela me retourne :
erreur de requete SET @a=0; SET @b=0; SET @c=0; SELECT date_format(date, '%Y-%M') as Mois, date_format(date, '%d') as Jour, MSISDN, if (count(TRANSACTION_ID) < 2, @a:=@a+1, '') as inf, if (count(TRANSACTION_ID) = 2, @b:=@b+1, '') as egal, if (count(TRANSACTION_ID) > 2, @c:=@c+1, '') as egal, count(TRANSACTION_ID) as Toute FROM `INDEX_EUROPE` GROUP BY Mois, Jour, MSISDN,

erreur Erreur de syntaxe près de '; SET @b=0; SET @c=0; SELECT date_format(date, '%Y-%M') as Mo' à la ligne 1