I'm currently trying to execute a query on a database of words. The database is organized such that I can access by first letter of the word, and by length of the word. However, I'm having trouble when I search using a letter and length:
//random letter sends an NSString with just a single letter from the English alphabet
NSString * randomLetter = [self randomLetter];
int characterCodeInASCII = [randomLetter characterAtIndex:0];
FMResultSet *rs = [db executeQuery:@"SELECT * FROM WORDS WHERE INDEXER=? AND LENGTH=?",characterCodeInASCII,length];
Unfortunately, the query isn't returning any values. I've tried this using a char as the input, as a string, and as an int.
I'm quite confused since I can do the same query using ruby:
list=db1.execute("SELECT * FROM WORDS WHERE INDEXER=110 AND LENGTH=7")
And get 453 results....
The sqlite table has the following columns:
>> db1.execute("SELECT * FROM sqlite_master")
=> [["table", "words", "words", 2, "CREATE TABLE words(word VARCHAR(15) PRIMARY KEY, indexer VARCHAR(1), length INTEGER)"], ["index", "sqlite_autoindex_words_1", "words", 3, nil]]
Any ideas on what I might be missing?
Thanks much!