Q:

Issue with query, it wont accept condition

I have this query here:
SELECT formas.*, SMS_SERVISI.IDTICKET, SMS_SERVISI.MBYLLUR,SMS_SERVISI.time_added
FROM formas 
LEFT JOIN SMS_SERVISI ON formas.ID = SMS_SERVISI.IDTICKET 
WHERE SMS_SERVISI.IDTICKET ='' or SMS_SERVISI.IDTICKET is null AND  formas.sektori_pergjegjes ='K' 
ORDER BY formas.id DESC;

My issue is, it won't accept the condition:
formas.sektori_pergjegjes ='K'

It's like it won't recognize it...
I need to show all records whose formas.sektori='K'
Could you please tell me if i'm putting it in the wrong place?
I have this condition everywhere, and it works...
Thanks..

A:

It's because you're not using parantheses. When one part of the OR condition becomes true, the rest is irrelevant.
SELECT formas.*, SMS_SERVISI.IDTICKET, SMS_SERVISI.MBYLLUR,SMS_SERVISI.time_added
FROM formas 
LEFT JOIN SMS_SERVISI ON formas.ID = SMS_SERVISI.IDTICKET 
WHERE (SMS_SERVISI.IDTICKET ='' or SMS_SERVISI.IDTICKET is null) AND  formas.sektori_pergjegjes ='K' 
ORDER BY formas.id DESC;

