par
JeanBap » 11 mars 2010, 20:59
Remarques:
les tables sont fausses essayent avec:
CREATE TABLE `evenements` (
`id` int(8) NOT NULL AUTO_INCREMENT,
`Nom` varchar(50) NOT NULL,
`Debut` date NOT NULL,
`Fin` date NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
CREATE TABLE `evenements_inscriptions` (
`inscr_id` int(8) NOT NULL AUTO_INCREMENT,
`evenement_id` int(8) NOT NULL,
`client_id` int(8) NOT NULL
PRIMARY KEY (`inscr_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
Dans tes tables tu as par exemple:
evenement
1, toto, 20091231, 20100101
2, toto1, 20091231, 20100101
evenement_inscription
1,1,12
2,2,13
Avec une jointure externe:
disons que ton client_id 14 n'est pas présent dans la table evenement_inscriptions...
SELECT evenements. *
FROM evenements
LEFT JOIN evenements_inscriptions ON evenement_id = id
AND client_id =14
WHERE evenement_id IS NULL
Remarques:
les tables sont fausses essayent avec:
[sql]
CREATE TABLE `evenements` (
`id` int(8) NOT NULL AUTO_INCREMENT,
`Nom` varchar(50) NOT NULL,
`Debut` date NOT NULL,
`Fin` date NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
CREATE TABLE `evenements_inscriptions` (
`inscr_id` int(8) NOT NULL AUTO_INCREMENT,
`evenement_id` int(8) NOT NULL,
`client_id` int(8) NOT NULL
PRIMARY KEY (`inscr_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
[/sql]
Dans tes tables tu as par exemple:
evenement
1, toto, 20091231, 20100101
2, toto1, 20091231, 20100101
evenement_inscription
1,1,12
2,2,13
Avec une jointure externe:
disons que ton client_id 14 n'est pas présent dans la table evenement_inscriptions...
[sql]
SELECT evenements. *
FROM evenements
LEFT JOIN evenements_inscriptions ON evenement_id = id
AND client_id =14
WHERE evenement_id IS NULL
[/sql]