So, exactly what the title states. I’d like to use a query like this:
NSString *querySQL = [NSString stringWithFormat:@"SELECT COUNT (*) FROM Devices WHERE Location LIKE '%@%'", name];
What it basically asks, is for example: SELECT COUNT (*) FROM Devices WHERE Location LIKE 'N%' . Then I’d like to find all the computers in building N, including all sublocations (like N33).
The question is: how do I insert the %-sign in the query? Currently, it shows 'N' only…
Use two % signs to escape %:
(of course, you need to sanitize your input, or use a parameterized query in the first place, to prevent SQL injection attacks)