Pb : requete sql ds mysql (pb de clef etrange

audrey -  
 vinnssou -
Voila g un pb avec mysql qui n'a pas l'air de gerer les clé etrangères.J'ai donc changé ma requete mais ca ne marche tjrs pas...
On considere 2 tables ici : une avec

Type_form (id_type_form, type_form)
formation (id_form, diplome,niveau,#id_type_form)

Au debut premiere requete:
"select id_type_form, type_form from type_form,formation where formation.niveau='2' and formation.id_type_form=type_form.id_type_form"

Mais mysql m'a repondu :
"MySQL a répondu: Champ: 'id_type_form' dans field list est ambigu "

J'ai donc changé ma requete:
"select id_type_form, type_form from type_form where id_type_form in (select id_type_form from formation where niveau='2')"
Mais MySQL a répondu: "Something is wrong in your syntax près de 'select id_type_form from formation where niveau='2') LIMIT 0, 30' à la ligne 1 "
Je ne vois absolument pas ce ki cloche...si qql pouvait m'aider!!!
merci d'avance !! :)

2 réponses

doue
 
id_type_form est défini dans les tables formation et type_form donc quand tu fais un select il faut préciser de quelle table il s'agit :
"select formation.id_type_form, type_form from type_form,formation where formation.niveau='2' and formation.id_type_form=type_form.id_type_form" fera l'affaire
0
vinnssou
 
essaye de renomer ta clef etrangere dans la table formation ou essaye avec des alias
0