Page 1 sur 1

probleme requete

Posté : 23 mai 2006, 13:12
par noobsql
Bonjour à tous,

J'ai 2 tables : actions et intervenants actions liés par le champs id_action.
A une action il peut y avoir plusieurs intervenants.

Exemple : dans la table action j'ai l'action (id = 15) avec un libellé, une date debut, date fin.
dans ma table intervenants, j'aurais comme intervenants, toto, titi, tata et pour chaque intervenants j'aurais l'id de l'action correspondant (id = 15).

Mon souci, lorsque je fais ma requête, je souhaite n'avoir qu'une fois l'action. Or comme il y a la liaison, il m'affiche autant de lignes qu'il peut y avoir d'intervenants pour l'action...

Comment faire ?

Voici ma requete :

Code : Tout sélectionner

select * from actions, intervenants_actions where (actions.id_actions = intervenants_actions.id_action) and (actions.date_debut='$_GET[date_debut]' or actions.date_fin='$_GET[date_debut]') and (actions.id_actions_statut != '4' and actions.id_actions_statut != '5')"
Merci de votre aide !

@+ tard

...

Posté : 23 mai 2006, 13:18
par noobsql
J'oublié, j'utilise mysql 3.23 (et oui, cadre national dans ma boite, pas encore mise à jour...)

@+

Posté : 23 mai 2006, 13:42
par Cyrano
Ajoute un élément à ta requête :

Code : Tout sélectionner

select * from actions, intervenants_actions where (actions.id_actions = intervenants_actions.id_action) and (actions.date_debut='". $_GET[date_debut] ."' or actions.date_fin='". $_GET[date_debut] ."') and (actions.id_actions_statut != '4' and actions.id_actions_statut != '5') AND actions.id_actions = 15;

Posté : 23 mai 2006, 14:12
par Invité
Ajoute un élément à ta requête :

Code : Tout sélectionner

select * from actions, intervenants_actions where (actions.id_actions = intervenants_actions.id_action) and (actions.date_debut='". $_GET[date_debut] ."' or actions.date_fin='". $_GET[date_debut] ."') and (actions.id_actions_statut != '4' and actions.id_actions_statut != '5') AND actions.id_actions = 15;
Salut et merci pour cette réponse.
Mais ça ne fonctionne pas, lorsque je rajoute ce que tu me dits, je n'ai plus aucun résultats...
Je cherche !

@+

Posté : 23 mai 2006, 14:21
par Invité
C'est bon, j'ai trouvé !
J'ai fait un "group by actions.id_actions" et ç'est nickel.

@+