bonsoir
j'ai besoin de votre aide svp
j'ai une table match qui comme structure:

idMatch int
idComp int
compositionPrincipale varchar
heure timestamp on update CURRENT_TIMESTAMP
stade varchar
idEquipe1 int
idEquipe2 int

je veux faire une requete qui me retourne (idMatch) des derniers match c a d ceux dont la date est inferieure à date system et cela pour chaque competition (idComp)

j'ai fait la requete suivante:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
SELECT idMatch 
FROM match 
GROUP BY idComp 
HAVING MAX(heure) < CURRENT_TIMESTAMP
mais en vain, si qqn pourra m'aider je serez reconnaissante

voici le script de creation de la table match et de son remplissage pourque vous puissiez tester et voir le resultat

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
19
20
21
22
23
24
--
-- Structure de la table `match`
--
 
CREATE TABLE IF NOT EXISTS `match` (
  `idMatch` int(10) NOT NULL AUTO_INCREMENT,
  `idComp` int(11) NOT NULL,
  `compositionPrincipale` varchar(255) NOT NULL,
  `heure` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `stade` varchar(255) NOT NULL,
  `idEquipe1` int(11) NOT NULL,
  `idEquipe2` int(11) NOT NULL,
  PRIMARY KEY (`idMatch`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
 
--
-- Contenu de la table `match`
--
 
INSERT INTO `match` (`idMatch`, `idComp`, `compositionPrincipale`, `heure`, `stade`, `idEquipe1`, `idEquipe2`) VALUES
(1, 2, '445', '2012-04-01 15:10:24', 'du nord', 1, 2),
(2, 1, '551', '2012-06-05 12:37:51', 'du nord', 2, 1),
(3, 1, '445', '2012-04-02 15:10:09', 'du nord', 3, 1),
(4, 1, '551', '2012-04-04 12:51:44', 'du nord', 1, 4);