I am trying to write a SQL query for FMDB I have in my Objective C project.
My table consists of an id, num_of_items, startDate, endDate.
My query looks like this
FMResultSet * result = [database executeQuery:@"SELECT * FROM mytablename WHERE date BETWEEN ? AND ? ", lstartDate, lendDate];
however when this code runs I am getting the following error after the app crashes
[1210:2007096] DB Error: 1 "near "TRUNCATE": syntax error"
[1210:2007096] DB Query: TRUNCATE mytablename
The date column contains long values, I have checked both lstartDate and lendDate both of which are in the database table in that column.
The result I am after is that all values between and including start and end date are included in the output.
Try putting a single quote ' either side of the ?. Like this:
FMResultSet * result = [database executeQuery:@"SELECT * FROM mytablename WHERE date BETWEEN '?' AND '?' ", lstartDate, lendDate];