-1

I need to create a complex SQLite statement.

I need a SQLite statement like this

if ((part ==1 || part == 2) && isFree==YES)

I created statement like this

@"SELECT * FROM book abook WHERE abook.part=0 OR abook.part=1 AND abook.isFree!=0"

Could you check please. Is it a correct statement?

MPelletier
  • 16,256
  • 15
  • 86
  • 137
Voloda2
  • 12,359
  • 18
  • 80
  • 130

2 Answers2

4

Try this

SELECT * FROM book abook WHERE (abook.part=0 OR abook.part=1) AND abook.isFree!=0
rs.
  • 26,707
  • 12
  • 68
  • 90
2

You need to use brackets:

SELECT * FROM book abook WHERE (abook.part=0 OR abook.part=1) AND abook.isFree!=0
GManz
  • 1,548
  • 2
  • 21
  • 42