-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
  • 15,673
  • 14
  • 84
  • 131
Voloda2
  • 12,009
  • 18
  • 78
  • 128

2 Answers2

4

Try this

SELECT * FROM book abook WHERE (abook.part=0 OR abook.part=1) AND abook.isFree!=0
rs.
  • 25,567
  • 12
  • 63
  • 89
2

You need to use brackets:

SELECT * FROM book abook WHERE (abook.part=0 OR abook.part=1) AND abook.isFree!=0
Hosh Sadiq
  • 1,484
  • 2
  • 21
  • 41