【问题标题】:Sqlite advanced searchSqlite 高级搜索
【发布时间】:2012-04-09 07:25:03
【问题描述】:

我正在为商店开发一个安卓应用程序,它提供了许多功能。其中之一是允许客户使用某些标准(价格、尺寸、类型...如图所示)搜索产品的功能。

我想我应该使用SqliteDatabase,但我不知道如何制作这个多条件搜索界面,以便用户可以查询数据库。

【问题讨论】:

    标签: android database sqlite search


    【解决方案1】:

    这很简单。设置好数据库后,您可以使用 SQL 查询和 JOIN 类型与 WHERE critaria 并最终获得正确的数据,使用 Cursor 类遍历结果。

    见: http://www.codinghorror.com/blog/2007/10/a-visual-explanation-of-sql-joins.html

    http://www.w3schools.com/sql/sql_where.asp

    http://www.w3schools.com/sql/sql_and_or.asp

    http://www.w3schools.com/sql/sql_join_inner.asp

    【讨论】:

      【解决方案2】:

      在处理它之前,您应该正确设计您的数据库。 认为, 表格列表 -

      1) product_type(_id<should be primary key to link another table>, 
         type_id<integer>, type_name<text>
      2) product_price(_id<should be primary key to link another table>, 
         type_id<integer>, price<double>
      3) product_type_size(_id<should be primary key to link another table>, type_id<integer>, size<text>
      

      并根据您的要求创建视图 - product_search(正确加入你的表) 并根据需要运行您的查询并与视图的值相匹配。

      继续--

      【讨论】:

        猜你喜欢
        • 2011-12-25
        • 1970-01-01
        • 2012-03-11
        • 2018-07-13
        • 2015-04-17
        • 2015-04-06
        • 2018-11-05
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多