I'm having trouble getting the FMDB wrapper for iOS to work with a parameter and a LIKE clause. In fact I'm having trouble getting the LIKE clause to work at all on SQLite with FMDB.
I've tried using `Name LIKE '%dam%' to match "Adam", and I've tried specifying it as a parameter as below, but none works.
[buffer appendString:@" Name LIKE '%dam%' "]; // no results
[buffer appendString:@" Name LIKE ? "];
[params addObject:[NSString stringWithFormat:@"%%%@%%", args.name]]; // no results
[buffer appendString:@" Name LIKE '%' ? '%' "];
[params addObject:[NSString stringWithFormat:@"%%%@%%", args.name]]; // no results
There are definitely items in the table which match the criteria, I just can't see why FMDB isn't returning them.
had this head ache one day too. try this
[buffer appendString:[NSString stringWithFormat:@" Name LIKE '%@dam%@' ",@"%",@"%"];