Sqlite Query 'AND'
I am stuck at a place where i am able to proceed with a sqlite SELECT query. My query is like this. I dont know if it tis correct or wrong. Please help me.
NSString *querySQL = [NSString stringWithFormat: @"SELECT * FROM CLAIMS WHERE DATE = \"%@\" AND TIME = \"%@\"",splitdate,splittime];
Any help is开发者_运维问答 appreciated. Thanks
SQL uses '
for strings, so at the very least your query should look like:
SELECT * FROM CLAIMS WHERE DATE = '%@' AND TIME = '%@'
A further step would be to make those things parameters:
SELECT * FROM CLAIMS WHERE DATE = @date AND TIME = @time
And a further improvement is to use the SQL type datetime
for the field so you'll only need one instead of 2:
SELECT * FROM CLAIMS WHERE DATE = @date
精彩评论