I build in sqlite3 3 tables. When I’m doing the following SELECT command:
select us.saleSpecificProduct,us.fAtMall,u.name,u.gender,st.storeName
from UsersSale us,Users u,Stores st
where u.userID=us.userID and st.storeID=us.saleStoreID order by us.saleID
It work ok in the shell, but if i put this statement in my iphone application I’m getting an error.
/*
* read items from the database and store in itemw
*
*/
-(void)readItems {
if (!database) return; // earlier problems
// build select statement
if (!selStmt)
{
const char *sql = "select us.saleSpecificProduct,us.fAtMall,u.name,u.gender,st.storeName from UsersSale us,Users u,Stores st where u.userID=us.userID and st.storeID=us.saleStoreID order by us.saleID";
if (sqlite3_prepare_v2(database, sql, -1, &selStmt, NULL) != SQLITE_OK)
{
selStmt = nil;
}
When I execute the application I get error in “sqlite3_prepare_v2”
}
What is wrong?
Maybe try putting your parameters inside single quotes
So something like:
Also you should make use of bindings to get safe statements:
e.g.