0

hi there I have a filed with publish=3 value

but this query print it!(it shouldn't)

 SELECT * FROM article WHERE publish BETWEEN 0 AND 2 AND feature = '1' 
 AND sid = '3' OR sid = '4' OR sid = '5' OR sid = '6' OR sid = '7' 
 OR sid = '8' OR sid = '9' OR sid = '10' AND created BETWEEN 0 
 AND 1446078164 ORDER BY id DESC LIMIT 0, 6                 

what is my wrong?

more info:

for where,there are 4 main clustered: WHERE publish BETWEEN 0 AND 2

AND feature = '1'

AND sid = '3' OR sid = '4' OR sid = '5' OR sid = '6' OR sid = '7' 
 OR sid = '8' OR sid = '9' OR sid = '10'

AND created BETWEEN 0 AND 1446078164
Dharman
  • 30,962
  • 25
  • 85
  • 135
partiz
  • 1,206
  • 2
  • 13
  • 34

1 Answers1

2

You need parentheses and probably in. I am guessing the logic you want is:

SELECT *
FROM article
WHERE publish BETWEEN 0 AND 2 AND
      feature = '1' AND
      sid IN ('3', '4', '5', '6', '7' , '8', '9', '10') AND
      created BETWEEN 0 AND 1446078164
ORDER BY id DESC
LIMIT 0, 6;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786