0

My question is about how to make searching query with two option. for example search by name and by keyword with sqlite database in android. can i make two tables for name and keyword or just one table?

3
  • Can you Please provide for which tables you want to make queries and what you want to search ? Commented Mar 19, 2018 at 6:03
  • You need to check this example : androidhive.info/2013/09/… Commented Mar 19, 2018 at 7:00
  • in my application i've made two tables.. one tbl_books and the others tbl_title_book and in searching queries i have two option for search.. 1.search by title book and 2.search by keyword Commented Mar 19, 2018 at 7:01

2 Answers 2

1

Something like this should work:

Cursor cusror = db.rawQuery("SELECT * FROM " + TABLE_A + " WHERE " + column_1_id + " = " + col_1_value + " AND " + column_2_id + " = " + col_2_value);

In your case, one table should be enough with name and keyword as column. Modify above query as required, like below.

column_1_id -> name
column_2_id -> keyword
Sign up to request clarification or add additional context in comments.

1 Comment

what is the function of col_1_value??
0

you can make single table and insert record when you search that time fire sql search query like below ..

        String selectQuery = "SELECT  * FROM " + MY_ITEMS_TABLE_NAME + " WHERE name=" + namevalue +", keyword=" +keywordvalue;
    Cursor c = db.rawQuery(selectQuery, null);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.