【问题标题】:Writing multiple queries编写多个查询
【发布时间】:2011-11-14 12:15:19
【问题描述】:

我已经编写了下面给出的查询,用于使用两个参数获取数据。您能否为此建议正确的 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];

【问题讨论】:

    标签: iphone ipad sqlite


    【解决方案1】:

    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];
    

    【讨论】:

    • 感谢您的快速响应。仅供参考,类别名称和美食名称是字符串。很抱歉这么说,但它仍然无法正常工作。
    • 什么错误?您确定查询正在返回行吗?
    • 无论如何,非常感谢。我得到了正确的答案。我们必须打破字符串然后处理。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-07-25
    • 2021-12-04
    • 2014-11-12
    • 2020-04-05
    • 2015-06-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多