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 7950953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:25:11+00:00 2026-06-04T02:25:11+00:00

I have a database from which I want to query and display only that

  • 0

I have a database from which I want to query and display only that data which has one type of similar field..
Say all rows have a day(Mon to sun) in them… I want to display all the rows that have Monday as the day…
I have used SimpleCursorAdapter to display all the rows from my database…
Basically, I want to know how i can query in SimpleCursorAdapter to display rows of the data having only say, Monday as the day…

Any help is appreciated…:)

The following code enables me to display all the data from my data base…

    protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.testlayout2);
     listContent = (ListView)findViewById(android.R.id.list);//.id..list);
    mDB = new DataSource(this);
    mDB.open();

    cursor = mDB.queueAll();
    String[] from = new String[]{
            MySQLiteHelper.KEY_START, MySQLiteHelper.KEY_END,
            MySQLiteHelper.KEY_SUBJECT, MySQLiteHelper.KEY_LOC,
            MySQLiteHelper.KEY_TEACHER };
    int[] to = new int[] {R.id.tvStart, R.id.tvEnd,
            R.id.tvSub, R.id.tvLoc, R.id.tvTeacher };


            cursorAdapter = new SimpleCursorAdapter(this, R.layout.row, cursor,
            from, to);

        listContent.setAdapter(cursorAdapter);
        listContent.setOnItemClickListener(listContentOnItemClickListener);
    }

}

I want the query to be like this..

  Cursor cursor = db.query(table, null, "day like " + "'%Monday%'",null, 
                                 null, null, null);

Got that… Sorry for the trouble. Please tell me where i am going wrong with this though..
I made this in the code to query the day and sort ascending by time..

 public Cursor queryDay(String days) {
    Cursor cursor = mDatabase.query(DATABASE_TABLE, mAllColumns, "day like " + 
                     days, null, null, null, Database.KEY_START + " ASC");
    if (cursor.moveToNext()) {
        return cursor;
    }
    return cursor;
}

However, I get this error,

   android.database.sqlite.SQLiteException: no such column: Thursday: , 
   while compiling: SELECT _id, day,start_time, end_time, sub, location, 
   teacher FROM subjectTable WHERE day like Thursday ORDER BY start_time ASC

I am calling this like this..

 Cursor cursor = mDB.queryDay("Thursday");
 startManagingCursor(cursor);
  • 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-06-04T02:25:12+00:00Added an answer on June 4, 2026 at 2:25 am

    This solves the second part of the question..

        public Cursor queryDay(String days) {
        Cursor cursor = mDatabase.query(DATABASE_TABLE, mAllColumns, "day like " 
         + "'" + days + "'", null,null, null, Database.KEY_START + " ASC");
        if (cursor.moveToNext()) {
            return cursor;
        }
        return cursor;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of e-mails from one database which I want to check
I have a variable which I get from database I want to output this
I have a DataTable which I select from database (Well, these data cross several
I have SMO code which copies tables from one database to another. It runs
I have a Linq query that returns an anonymous type, which I then use
I have a php array to display information from a database. I want to
i have a mysql database from which i require an rss feed of its
I have a database connection which takes an input from the querystring to access
I have a function which calculates distance from database records. This function is called
i have a combobox which is displaying date from database...in my database the date

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.