Query does not return WHERE set

0

I'm trying to query the Informix Database, and it's bringing in the data normally, but it's ignoring the search criteria.

SELECT cnnfcapa.id_nfcapa,   
cnnfcapa.filial, cnnfitem.tpordem, 
cnnfcapa.ordemserv, cnnfcapa.dtnota,  
cnnfcapa.cgccpf, 
cnnfcapa.tppessoa, cnnfcapa.transacao, 
cttransa.mvtotransacao, 
cttransa.tipotransacao, 
cnnfcapa.id_agente, 
cnnfcapa.id_agentvext, 
cnnfitem.descritem, cnnfitem.mercadoria, 
cnnfitem.quantidade, 
cnnfitem.valoritem
FROM cnnfcapa 
INNER JOIN cnnfitem ON 
cnnfcapa.id_nfcapa = cnnfitem.id_nfcapa
INNER JOIN cttransa ON 
cnnfcapa.transacao = cttransa.transacao
WHERE dtnota BETWEEN "01/01/2015" 
AND "31/12/2015"
AND cttransa.mvtotransacao="S" 
AND cttransa.tipotransacao=10 
OR cttransa.tipotransacao=15 
OR cttransa.tipotransacao=30
OR cttransa.tipotransacao=35

The result looks like this:

    
asked by anonymous 19.10.2017 / 04:05

1 answer

1

Your OR are not being interpreted the way you expect, and are being applied to all AND together. Here's how:

WHERE dtnota BETWEEN "01/01/2015" AND "31/12/2015"
AND cttransa.mvtotransacao="S" 
AND cttransa.tipotransacao IN(10, 15, 30, 35)
    
19.10.2017 / 04:12