我有这个问题。 我使用这个查询:
"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'
没有执行。也许我做了一个错位,或其他什么,但我无法让它工作。
请看一下。 感谢
答案 0 :(得分: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'
答案 1 :(得分: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' "
答案 2 :(得分: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'"