从iPhone中的sqlite中检索数据

时间:2012-07-11 08:46:47

标签: iphone objective-c sqlite

我有5列(type_id,Type,Quantity,NumberCalories,Category_id),我需要根据更改“type”检索“Category_id”。请帮助我,他的是我的代码

const char *sql = "select type_id,Type,Quantity,NumberCalories from FoodType where Category_id=?";

1 个答案:

答案 0 :(得分:0)

categoryId 传递给数据库方法并修改您的查询,如下所示

NSString *sqlQuery =[NSString stringWithFormat:@"select type_id,Type,Quantity,NumberCalories from FoodType where Category_id = %d",categoryId];

const char *sql= [sqlQuery UTF8String];