0
SELECT t1.* FROM HOSTS AS t1
WHERE
t1.BOSS = 'BRUCE'
OR ( t1.BOSS_TYPE = 'manager'
 AND t1.BOSS_ID = 'BRUCE' )
OR t1.BOSS IN ( SELECT t2.STORES FROM
  FOLLOW_STORES AS t2 
 WHERE t2.BOSSES = 'BRUCE' )

上記のクエリはうまく機能しますが、JOIN を追加して追加情報を取得したい

この JOIN を追加したいのですが、うまくいきません。挿入する場所を間違えているに違いない。

 JOIN MANAGER_POSTS AS t3 ON ( t1.POSTER_ID = t3.POSTER_ID
    AND t1.SUBMISSION_TYPE =  'post' )

この追加情報を取得するために結合を追加する正しい方法は何ですか?

4

2 に答える 2

1

ここでこれを試してください:

SELECT  t1.* , t3.*
FROM    HOSTS AS t1 
            INNER JOIN MANAGER_POSTS AS t3 
                ON ( t1.POSTER_ID = t3.POSTER_ID AND 
                     t1.SUBMISSION_TYPE =  'post' )
WHERE   t1.BOSS = 'BRUCE' 
        OR (t1.BOSS_TYPE = 'manager' AND t1.BOSS_ID = 'BRUCE' )
        OR t1.BOSS IN   ( 
                            SELECT t2.STORES 
                            FROM FOLLOW_STORES AS t2 
                            WHERE t2.BOSSES = 'BRUCE' 
                        )
于 2012-07-30T10:16:38.847 に答える
0

あなたの後とあなたの前にあなたのJOIN句を追加する必要がありますFROM HostsWHERE

SELECT t1.* 
FROM HOSTS AS t1
INNER JOIN MANAGER_POSTS AS t3 
    ON ( t1.POSTER_ID = t3.POSTER_ID
    AND t1.SUBMISSION_TYPE =  'post' )
WHERE t1.BOSS = 'BRUCE'
    OR ( t1.BOSS_TYPE = 'manager'
          AND t1.BOSS_ID = 'BRUCE' )
    OR t1.BOSS IN ( SELECT t2.STORES 
                    FROM FOLLOW_STORES AS t2 
                    WHERE t2.BOSSES = 'BRUCE' )
于 2012-07-30T10:16:27.947 に答える