sql >> データベース >  >> RDS >> Oracle

あいまいな列クエリ

    少なくとも同じクエリでは、WHERE句内のSELECT句で列エイリアスを参照することはできません。サブクエリを実行することも、元の列参照を使用することもできます。

    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
    bolanguages."LANGUAGE" = :P19_LANGUAGE
    or
    bolanguages2."LANGUAGE" = :P19_LANGUAGE)
    AND
    (:P19_GENRE = 'all' 
    or
    bogenres."NAME" = :P19_GENRE)
    AND
    (replace(:P19_OWNER, ' ', '') = '' 
    or
    bobooks.owner like '%'||:P19_OWNER||'%');
    


    1. スペースmysqlでテーブルの名前を変更します

    2. 雄弁なものを使用した行とグループの合計

    3. Webページ内でセッションを使用する方法は?

    4. BigIntegerをMysqlに保存する