運行此查詢時,我得到了「不明確的列」的錯誤,但我有一個很難找到的原因:不明確的列查詢
select bobooks.ID request,
bobooks.TITLE,
bobooks.AUTHOR,
bogenres.NAME genre,
bobooks.OWNER,
bostatus.NAME status,
bolanguages.LANGUAGE language,
bolanguages2.LANGUAGE secondary_language
from BO_BOOKS bobooks
inner join BO_GENRES bogenres
on bobooks.genre = bogenres.id
inner join BO_STATUS bostatus
on bobooks.status = bostatus.id
inner join BO_LANGUAGES bolanguages
on bobooks.language = bolanguages.id
left outer join BO_LANGUAGES bolanguages2
on bobooks.secondary_language = bolanguages2.id
where (replace(:P19_AUTHOR, ' ', '') = '' or
bobooks.author like '%'||:P19_AUTHOR||'%') AND
(replace(:P19_TITLE, ' ', '') = '' or
bobooks.title like '%'||:P19_TITLE||'%') AND
(:P14_LANGUAGE = 'all' or
language = :P19_LANGUAGE or
secondary_language = :P19_LANGUAGE) AND
(:P19_GENRE = 'all' or
genre = :P19_GENRE) AND
(replace(:P19_OWNER, ' ', '') = '' or
bobooks.owner like '%'||:P19_OWNER||'%');
我會搞亂的列嗎?
非常感謝你的時間!
很難說沒有看到你的模式,但看着你的WHERE子句,你沒有別名你的列。在每個列上放置別名,您的問題應該消失。 –
沒有你的模式,這是不可能的。但它必須是非完全限定的列之一,因此要使它們都完全合格。 – Donnie
在你的WHERE子句中,你有非限定的'language','secondary_language'和'genre'。它一定是其中之一。 – Barmar