Besoin d'un requete SQL

Résolu
cs_cy4nur3 Messages postés 17 Date d'inscription mardi 3 mai 2005 Statut Membre Dernière intervention 27 mai 2010 - 26 mai 2010 à 15:34
cs_cy4nur3 Messages postés 17 Date d'inscription mardi 3 mai 2005 Statut Membre Dernière intervention 27 mai 2010 - 27 mai 2010 à 09:06
Bonjour a vous,

voila j'ai un soucis. j'ai deux tables et je voudrais obtenir qu'un seul tableau
voici la premiere table:

CREATE TABLE IF NOT EXISTS `joueur_1` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `ronde` int(10) DEFAULT NULL,
  `joueur_id` varchar(50) DEFAULT NULL,
  `couleur` varchar(10) DEFAULT NULL,
  `point` varchar(10) DEFAULT NULL,
  `tournois_id` int(10) DEFAULT NULL,
  `appariement` int(10) DEFAULT NULL,
  `table` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;


CREATE TABLE IF NOT EXISTS `joueur_2` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `ronde` int(10) DEFAULT NULL,
  `joueur_id` varchar(50) DEFAULT NULL,
  `couleur` varchar(10) DEFAULT NULL,
  `point` varchar(10) DEFAULT NULL,
  `tournois_id` int(10) DEFAULT NULL,
  `appariement` int(10) DEFAULT NULL,
  `table` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;



et moi ce que je voudrais obtenir c'est un tableau sous la forme:

joueur1_____point1____joueur2____point2 ___ronde__tournois
.
.
.
et la liste de ce que je demande.

j'ai fait un requete mais elle ne ne fonctionne pas(resultat pas correct). Merci de m'aider.

Voici la requete:

SELECT joueur_1.joueur_id, joueur_1.point, joueur_2.joueur_id, joueur_2.point
FROM joueur_1, joueur_2
WHERE joueur_1.tournois_id = joueur_2.tournois_id
AND joueur_1.ronde = joueur_2.ronde
AND joueur_1.tournois_id =1
AND joueur_1.ronde =1



Cordialement

2 réponses

cs_cy4nur3 Messages postés 17 Date d'inscription mardi 3 mai 2005 Statut Membre Dernière intervention 27 mai 2010
27 mai 2010 à 09:06
solution:

SELECT j1.joueur_id AS joueur1, j1.point AS point1, j2.joueur_id AS joueur2, j2.point AS point2, j1.ronde AS ronde, j1.tournois_id AS tournois
FROM joueur_1 AS j1
JOIN joueur_2 AS j2 ON j2.ronde = j1.ronde
AND j2.tournois_id = j1.tournois_id
AND j2.table = j1.table
3
devil_may_cry Messages postés 194 Date d'inscription dimanche 18 mars 2007 Statut Membre Dernière intervention 11 juillet 2015
27 mai 2010 à 06:11
salut
tu peut essayer
SELECT *
FROM joueur_1 INNER JOIN joueur_2
USING (id)
0
Rejoignez-nous