0

この質問があります。私が使用するこのクエリがあります:

"SELECT  formas.*,
        SMS_SERVISI.IDTICKET,
        SMS_SERVISI.MBYLLUR,
        SMS_SERVISI.time_added,
        servis_furnitor.id_servis,
        servis_furnitor.furnitori,
        servis_furnitor.kohezgjatja,
               referenca.id_referenca,
        referenca.shenime

FROM formas
LEFT JOIN servis_furnitor
        ON formas.furnitori = servis_furnitor.id_servis
LEFT JOIN SMS_SERVISI
        ON formas.ID = SMS_SERVISI.IDTICKET
        AND formas.sektori_pergjegjes ='A'
        LEFT JOIN referenca
        ON formas.ID = referenca.id_referenca  "

私の問題は、条件の一部がAND formas.sektori_pergjegjes ='A' 実行されないということです。置き忘れなどをしたのかもしれませんが、うまくいきません。

こちらをご覧ください。ありがとう

4

3 に答える 3

1

条件AND formas.sektori_pergjegjes ='A'は結合条件の一部であるため、結合結果に対してのみ実行されます。すべてのデータをフィルターに準拠させる場合は、データをwhere句に移動する必要があります。

SELECT  formas.*,
        SMS_SERVISI.IDTICKET,
        SMS_SERVISI.MBYLLUR,
        SMS_SERVISI.time_added,
        servis_furnitor.id_servis,
        servis_furnitor.furnitori,
        servis_furnitor.kohezgjatja,
        referenca.id_referenca,
        referenca.shenime    
FROM formas
LEFT JOIN servis_furnitor
        ON formas.furnitori = servis_furnitor.id_servis
LEFT JOIN SMS_SERVISI
        ON formas.ID = SMS_SERVISI.IDTICKET
LEFT JOIN referenca
        ON formas.ID = referenca.id_referenca
WHERE formas.sektori_pergjegjes ='A'
于 2013-03-15T09:36:39.910 に答える
0

and条件をwhereとして配置し、それが解決するかどうかを確認します

"SELECT  formas.*,
        SMS_SERVISI.IDTICKET,
        SMS_SERVISI.MBYLLUR,
        SMS_SERVISI.time_added,
        servis_furnitor.id_servis,
        servis_furnitor.furnitori,
        servis_furnitor.kohezgjatja,
               referenca.id_referenca,
        referenca.shenime

FROM formas
LEFT JOIN servis_furnitor
        ON formas.furnitori = servis_furnitor.id_servis
LEFT JOIN SMS_SERVISI
        ON formas.ID = SMS_SERVISI.IDTICKET

        LEFT JOIN referenca
        ON formas.ID = referenca.id_referenca 
 WHERE formas.sektori_pergjegjes ='A' "
于 2013-03-15T09:35:24.187 に答える
0

試す:

"SELECT  formas.*,
    SMS_SERVISI.IDTICKET,
    SMS_SERVISI.MBYLLUR,
    SMS_SERVISI.time_added,
    servis_furnitor.id_servis,
    servis_furnitor.furnitori,
    servis_furnitor.kohezgjatja,
           referenca.id_referenca,
    referenca.shenime

FROM formas
LEFT JOIN servis_furnitor
    ON formas.furnitori = servis_furnitor.id_servis
LEFT JOIN SMS_SERVISI
    ON formas.ID = SMS_SERVISI.IDTICKET
LEFT JOIN referenca
    ON formas.ID = referenca.id_referenca  
WHERE formas.sektori_pergjegjes ='A'"
于 2013-03-15T09:36:01.813 に答える