编写多个查询

时间:2011-11-14 12:15:20

标签: iphone ipad sqlite

我已经编写了下面给出的查询,用于获取具有两个参数的数据。您能否为此目的建议正确的SQL语法。

SQL查询:

FMResultSet *resultOfDesiredCuisine = [db executeQueryWithFormat:@"select * from dishes where cuisineId IN (select cuisineId from cuisines where  Lower(cuisineName) like %@) and 
        categoryID IN \"(select categoryID from categories where Lower(categoryName) like %@)",cuisineName,categoryName];

1 个答案:

答案 0 :(得分:0)

SQLite不使用%@语法,而是使用?

FMResultSet *resultOfDesiredCuisine = [db executeQueryWithFormat:@"SELECT * FROM dishes WHERE cuisineId IN (SELECT cuisineId FROM cuisines WHERE LOWER(cuisineName) like ?) AND 
        categoryID IN (SElECT categoryID FROM categories WHERE LOWER(categoryName) LIKE ?)", cuisineName, categoryName];