Hi ,
What's better way to format following sql statement considering both readability and performance. Thanks.
sql = (char *)" SELECT * ,rowid FROM tblEvent_basic "
" WHERE "
" service_id = ? AND "
" ("
" (start_time >= ? AND start_time <= ?) OR "
" (end_time > ? AND end_time <?) OR "
" (start_time < ? AND end_time > ?)"
" )"
" ORDER by start_time ASC";
EDIT: 1.sqlite3 Database engine ; using C API ;running on MIPS24K 250M Embedded CPU.
2.the 2nd , 4th , 6th parameter is same , and 3rd, 5th, 7th is same.
rc = sqlite3_bind_int(sql_stmt,1,service_id);
rc = sqlite3_bind_text(sql_stmt,2,ts.start, 5, SQLITE_TRANSIENT);
rc = sqlite3_bind_text(sql_stmt,3,ts.end , 5, SQLITE_TRANSIENT);
rc = sqlite3_bind_text(sql_stmt,4,ts.start, 5, SQLITE_TRANSIENT);
rc = sqlite3_bind_text(sql_stmt,5,ts.end , 5, SQLITE_TRANSIENT);
rc = sqlite3_bind_text(sql_stmt,6,ts.start, 5, SQLITE_TRANSIENT);
rc = sqlite3_bind_text(sql_stmt,7,ts.end , 5, SQLITE_TRANSIENT);