Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android SQL query with two "Where" clauses

Tags:

android

sqlite

Hello i have an SQL query and i want it to have two WHERE clause. I want it to query both Bid and Cid in my db and return it to a cursor there is my code

     public Cursor getSubCategoriesQuerybyCidandBid(String Cid, int Bid) {
        this.openDataBase();
        Cursor c;
         String[] asColumnsToReturn = new String[] {SECOND_COLUMN_ID, SECOND_COLUMN_IDENTITY, SECOND_COLUMN_SUBCATEGORIES};
         c =dbSqlite.query(false, TABLE_NAME, asColumnsToReturn, COLUMN_BID + "=" + Bid + COLUMN_CID + "=" + Cid , null, null, null, null, null);
         return c;
    }

This is how i want it to be but this is not working any ideas how to fix this?

like image 867
Stelios M Avatar asked Jun 22 '26 08:06

Stelios M


1 Answers

Try COLUMN_BID + "=" + Bid + " AND " + COLUMN_CID + "=" + Cid.

like image 183
Hauleth Avatar answered Jun 24 '26 22:06

Hauleth