2013-12-11 165 views
-1
select `Nom`,`Prenom` from 
`pi_photographes` 
where 
`IdPhotographe`=(select 
`IdPhotographe` 
from`pi_photos` 
where`Description`="Site de Palmyre"); 

基地 照片[IdPhoto,FichPhoto,尺寸,描述,IdPhotographe#,RefBien#]1242 - 子查詢返回多個1行

Photographes [IdPhotographe,喃,Prenom]

+1

這不是一個清晰的問題,也沒有表現出任何的研究工作。 – depquid

+2

錯誤意味着如果您執行語句'select piPhotographe from pi_photos where Description =「Site de Palmyre」'它返回多於一行。要麼你的數據是錯誤的,你應該解決這個問題,並添加適當的檢查,或者你的陳述是錯誤的,你應該添加'distinct'到混合中。 –

+0

這意味着您的pi_photos中有多個記錄,其中描述爲「Site de Palmyre」。 –

回答

0

您需要要使用IdPhotographe IN(subquery ...)作爲倍數和1,您需要限制您的子查詢通過在子查詢中放置限制來給出一條記錄,而使用=操作符時,您必須限制子查詢以提供一個結果

有一條記錄

select `Nom`,`Prenom` from 
`pi_photographes` 
where 
`IdPhotographe`=(select 
`IdPhotographe` 
from`pi_photos` 
where`Description`="Site de Palmyre" LIMIT 1); 

多個記錄的使用IN()

select `Nom`,`Prenom` from 
`pi_photographes` 
where 
`IdPhotographe` IN (select 
`IdPhotographe` 
from`pi_photos` 
where`Description`="Site de Palmyre"); 
相關問題