我在mysql上的代码出了什么问题?

时间:2013-12-15 20:35:37

标签: mysql

目标:Titre和Textedesc用法语表示不同的biens

Biens [ RefBien, Titre, Situation, GPS, EnPeril, DateInsc, Superficie, IdPhotoPrinc#,TypeBien ]
Langues [ IdLangue, Libelle ]
DescriptionsBiens [ RefBien#, IdLangue#, TexteDesc ]

我的代码出了什么问题?

SELECT  `TexteDesc` ,  `Titre` 
FROM  `pi_descriptionsbiens` ,  `pi_biens` 
where`pi_descriptionsbiens`.`RefBien` =  `pi_biens`.`RefBien` 
and`IdLangue` = ( SELECT  `IdLangue` FROM  `pi_langues` WHERE  `Libelle` =  "français" ) 
group by `RefBien`;

2 个答案:

答案 0 :(得分:0)

您应该使用联接,并将"替换为'

SELECT TexteDesc , Titre, pi_descriptionsbiens.RefBien
FROM pi_descriptionsbiens
JOIN pi_biens ON pi_descriptionsbiens.RefBien = pi_biens.RefBien 
and IdLangue=(SELECT IdLangue FROM pi_langues WHERE Libelle = 'français') 
group by pi_descriptionsbiens.RefBien;

另外,请确保返回值

SELECT IdLangue FROM pi_langues WHERE Libelle = 'français'

答案 1 :(得分:0)

也许你是在追求这样的事情......

  SELECT DISTINCT TexteDesc 
                , Titre  
             FROM pi_descriptionsbiens d
             JOIN pi_biens b
               ON d.RefBien =  b.RefBien 
             JOIN pi_langues l
               ON d.IdLangue = l.IdLangue 
            WHERE l.Libelle = "français"