Sqlite Like Function in objective C

SELECT count(*) from BOOKS where BOOKS.TAG_ID like '%,1,%'

I wanna Execute this query in Objective-C.

 const char *sql = "Select count(*) from Documents WHERE DocumentTag LIKE '%i,?,%i'";
 sqlite3_stmt *sqlStatement;
 NSString *bindParam = [NSString stringWithFormat:@"%d", tagId];
if(sqlite3_bind_int(sqlStatement, 1, tagId)!= SQLITE_OK){
    NSLog(@"Problem binding search text param.");
else if(sqlite3_prepare_v2(database, sql, -1, &sqlStatement, NULL)==SQLITE_OK)
    sqlite3_bind_int(sqlStatement, 1, sqlite3_column_int(sqlStatement, 0));



Parameter markers are not recognized inside string literals (otherwise, it would not be possible to use ? characters in strings).

You have to construct your LIKE pattern from three strings, your parameter and a prefix and a suffix:

const char *sql = "Select count(*) from Documents"
                  " WHERE DocumentTag LIKE '%i,' || ? || ',%i'";

Need Your Help

Get every second row as a result table in t-sql

sql sql-server tsql select

I'm looking for a t-sql script that returns a list, that shows every second value from a grouping from Table1.

element within ranges and distance between two points

matlab loops matrix range element

I have a 53534x3 matrix with x, y and z coordinates.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.