Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4244178
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:40:27+00:00 2026-05-21T03:40:27+00:00

Dear Stack Overflow Community, I have a question regarding how to incorporate a WHERE

  • 0

Dear Stack Overflow Community,

I have a question regarding how to incorporate a WHERE clause when querying a sql database in Android. My goal is to return specific records from my database where the date picked by a datepicker matches the date stored.

Here is my code:

private static String datePickerDate = "3/29/2011";
private static String[] FROM = { _ID, NAME, PRICE, DATE, TIME };
private static String ORDER_BY = TIME + " DESC ";
private static String WHERE = DATE + "is like " + datePickerDate;
private Cursor getEvents(){
    // Perform a managed Query. The Activity will handle closing
    // and re-querying the cursor when needed
    SQLiteDatabase db = events.getReadableDatabase();
    Cursor cursor = db.query(TABLE_NAME, FROM, null, null, null, null, ORDER_BY);
    startManagingCursor(cursor);
    return cursor;
}

My questions are thus:
Where does my “WHERE” statement go?

And is my “WHERE” statement correct?

The documentation I found for db.query doesn’t specify if a “WHERE” clause can be used, it just specifies that a “HAVING” clause is possible, but I don’t quite think that’s what I’m wanting.

 db.query(table, columns, selection, selectionArgs, groupBy, having, orderBy)   
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T03:40:28+00:00Added an answer on May 21, 2026 at 3:40 am

    The selection represents your WHERE clause.

    From the doc

    selection A filter declaring which
    rows to return, formatted as an SQL
    WHERE clause (excluding the WHERE
    itself). Passing null will return all
    rows for the given table.

    So you can try this (untested):

    private static String WHERE = "DATE like ?";
    db.query(table, columns, WHERE , new String[] { datePickerDate }, groupBy, having, orderBy)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Dear SQL Gurus from Stack Overflow: Environment: Oracle I'm trying to understand why I
Dear Stack Overflow Community, I am a Java programmer in front of a task
Dear Stack Overflow Community, I'm attempting to get the date from a datepicker and
Dear fellow readers on Stack Overflow, I am currently working in CSS and I
Dear all, I have a question about Facebook Page: ( NOT user profile page,
Dear all,Now i have this question in my java program,I think it should be
Dear All, please help me since I'm newbie in SQL Server. I have a
Hallo Dear Stackoverflow users. Working with sql on sql server I have searched the
Dear g++ hackers, I have the following question. When some data of an object
Dear stackoverflow community, I have a simple menu that have to be dynamics. With

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.