Bonjour,

J'ai 2 tables (chansons et etudiants), je voudrais affiches les etudiant avec les chanson qui ont ecoute ainsi que le type:

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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
 
 
--
-- Table structure for table `chansons`
--
 
CREATE TABLE IF NOT EXISTS `chansons` (
  `id` int(2) NOT NULL auto_increment,
  `idt` tinyint(2) NOT NULL,
  `chanson` varchar(20) collate latin1_general_ci NOT NULL,
  `type` tinyint(2) NOT NULL,
  `ref` tinyint(2) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=10 ;
 
--
-- Dumping data for table `chansons`
--
 
INSERT INTO `chansons` (`id`, `idt`, `chanson`, `type`, `ref`) VALUES
(1, 1, 'Chanson1', 1, 1),
(2, 1, 'Chanson2', 1, 0),
(3, 1, 'Chanson3', 2, 0),
(4, 2, 'Chanson2', 2, 0),
(5, 1, 'Chanson1', 2, 0),
(6, 1, 'Chanson1', 3, 0),
(7, 1, 'Chanson1', 1, 1),
(8, 1, 'Chanson1', 1, 1),
(9, 1, 'Chanson1', 1, 0);
 
-- --------------------------------------------------------
 
--
-- Table structure for table `etudiants`
--
 
CREATE TABLE IF NOT EXISTS `etudiants` (
  `id` int(2) NOT NULL auto_increment,
  `nom` varchar(20) collate latin1_general_ci NOT NULL,
  `prenom` varchar(20) collate latin1_general_ci NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=3 ;
 
--
-- Dumping data for table `etudiants`
--
 
INSERT INTO `etudiants` (`id`, `nom`, `prenom`) VALUES
(1, 'Jean', 'Jacque'),
(2, 'Franklin', 'Albert');
type veut dire: type de la chanson (genre: rock,..) et ref (quelle reference: CD, Site,..)

je veux mettre des resultats sans doubler le type et ref du meme etudiant.

le resultat souhaitable est:
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
 
Jean Jacque:
'Chanson1', 1, 1
 
Jean Jacque:
'Chanson2', 1, 0
 
Jean Jacque:
'Chanson3', 2, 0
 
Jean Jacque:
'Chanson1', 2, 0
 
Jean Jacque:
'Chanson1', 3, 0
 
 
Albert Franklin:
'Chanson2', 2, 0
J'ai fait DISTINCT, mais ca marche pas avec 2 champs.

merci