I have an SQLite database which contains three columns: ID
, Name
, Dept
. I have one main ViewController
in which I have three fields: enter mobileNumber
(a textField), Name
(a label), and Dept
(a label). When i enter first 4 digit of any number in the textfield, the two labels automatically show the relevant value from the database. i am getting output fine when i give a default value in database. what i need is without giving any default value in database i want to run my app directly when i enter any number it should show the value of Name and Dept to the label. My database contains more than 3000 records.
i am using this query to get data from database:
sqlStatement = [[NSString stringWithFormat:@"SELECT _id,Name,Dept FROM Codes
WHERE _id=\'%@\'",idString.text]UTF8String];
I Assume
Things to try to debug this:
Use LIKE Clause
which will return relative outputs.
sqlStatement = [[NSString stringWithFormat:@"SELECT _id,Name,Dept FROM Codes WHERE _id like '%%@'",idString.text]UTF8String];
It will return you matching results as per your id.
For more clarity on LIKE Clause
please check this Link .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.