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

  • Home
  • SEARCH
  • 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 8663771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:04:06+00:00 2026-06-12T17:04:06+00:00

enter code here I am trying to write a query to extract all rows

  • 0

enter code hereI am trying to write a query to extract all rows in my Android SQLite database table where the location reference = “a string”. I am using the following code in my database helper class:

public Cursor fetchComponentsForLocation(String locationRef) {
    Cursor mCursor =
            rmDb.query(true, LOCATIONS_TABLE, new String[] {
                    LOCATION_ID, RUN_LINK, AREA_LINK, INSPECTION_LINK, LOCATION_REF, RACKING_SYSTEM, COMPONENT, POSITION, RISK, ACTION_REQUIRED, NOTES_GENERAL, MANUFACTURER, TEXT1, TEXT2, TEXT3, TEXT4, NOTES_SPEC}, 
                    LOCATION_REF + "=" + locationRef, null,
                    null, null, null, null);
        if (mCursor != null) {
            mCursor.moveToFirst();
        }
        return mCursor;
}

And I call it in my activity as follows:

    // Get a Cursor for the list items
    Cursor listComponentCursor = rmDbHelper.fetchComponentsForLocation(locationRef);
    startManagingCursor(listComponentCursor);           

    // set the custom list adapter     
    setListAdapter(new MyListAdapter(this, listComponentCursor)); 

Which then gets used in my ListAdapter to fill my list view. Now in my other activities, when I am fetching rows based on the id (i.e. a long), this code works fine. When I try it with String I get the following error:

Caused by: android.database.sqlite.SQLiteException: **no such column: g:** , while compiling: SELECT DISTINCT _id, run_link, area_link, inspection_link, location_reference, racking_system, component, position, risk, action_required, notes_general, manufacturer, text1, text2, text3, text4, notes_spec FROM location_table WHERE location_reference=g

As you can see, in this case the String = ‘g’, but it seems to looking for a column called ‘g’ instead of looking at the data!

Very confused why this works with long but not String. Help appreciated as always.

  • 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-12T17:04:07+00:00Added an answer on June 12, 2026 at 5:04 pm

    I think you are missing a couple of single quotes around the string you are searching for:

    LOCATION_REF + "='" + locationRef+"'", null,
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

enter code here My problem is this: in this database the junction table contains
I'm trying to write a mysql class... enter code here class ASQL { public
enter code here I have a table on SQL server 2005 with bigint primary
enter code here Hi All, I have a simple windows service application that connects
I have <.ImageView> enter code here s(icons) in my android layout xml file, which
i can't find any mistakes in my code. here i'm trying to pick all
enter code here Want to remove items from a Main list , but give
enter code here My jquery ui dialog contains an iframe and has the option
enter code here I have a ListView that have a different Layout XML for
I check like this: enter code here var point = new g.LatLng(parseFloat(lat),parseFloat(lng)); var bounds

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.