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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:10:57+00:00 2026-05-27T23:10:57+00:00

I have a Database With a foreign key I am using the SELECT *

  • 0

I have a Database With a foreign key I am using the SELECT * FROM statement but I keep getting an error when I try to view the database.

SELECT * FROM STATEMENT

 private final String MY_QUERY = "SELECT * FROM wwTable mLat INNER JOIN wwTimeTable _id ON wwTable._id=wwTimeTable.mName WHERE Table._id=wwTimetabel.mForeign";

MY KEYS

public static final String KEY_ROWID = "_id";
public static final String KEY_ROWIDLL = "_id";
public static final String KEY_ROWIDTIME = "_id";
public static final String KEY_NAME = "mName";
public static final String KEY_LAT = "mLat";
public static final String KEY_LON = "mLon";
public static final String KEY_HOUR = "mHour";
public static final String KEY_MINUT = "mMinut";
public static final String KEY_DAY = "mDay";
public static final String KEY_MONTH = "mMonth";
public static final String KEY_YEAR = "mYear";
public static final String KEY_FOREIGN = "mForeign";

ONCREATE EXECSQL

 @Override
        public void onCreate(SQLiteDatabase db) {
            // TODO Auto-generated method stub
            db.execSQL("CREATE TABLE " + WW_TABLE + 
                    " (" + KEY_ROWIDLL + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
                    KEY_LAT + " TEXT NOT NULL, " + 
                    KEY_LON + " TEXT NOT NULL);");
            db.execSQL("CREATE TABLE " + WW_TIMETABLE + 
                    " (" + KEY_ROWIDTIME + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
                    KEY_HOUR + " TEXT NOT NULL, " +
                    KEY_FOREIGN + " INTEGER," +
                    " FOREIGN KEY ("+KEY_FOREIGN+") REFERENCES "+WW_TABLE+" ("+KEY_ROWIDLL+") ON DELETE CASCADE);");

CURSOR RAWQUERY

  public Cursor fetchTime() {
        // TODO Auto-generated method stub
        //return ourdb.query(WW_TIMETABLE, new String[] {KEY_ROWIDTIME, KEY_HOUR, KEY_FOREIGN}, null, null, null, null, null);
        return ourdb.rawQuery(MY_QUERY, new String[]{String.valueOf(KEY_FOREIGN)});

    }

HOW I VIEW ALL OF IT INSIDE OF A LISTACTIVITY

private void fillData() {
     // Get all of the rows from the database and create the item list

    mTimeNotesCursor = mDbHelper.fetchTime();
    startManagingCursor(mTimeNotesCursor);
   // startManagingCursor(mNotesCursor);

    // Create an array to specify the fields we want to display in the list (only TITLE)
    String[] from = new String[]{WWDatabase.KEY_HOUR,WWDatabase.KEY_FOREIGN};

    //String[] fromTime = new String[]{WWDatabase.KEY_HOUR};


    // and an array of the fields we want to bind those fields to (in this case just text1)
    int[] to = new int[]{R.id.textView2, R.id.textView3};

   //int[] toTime = new int[]{R.id.textView4};

    // Now create a simple cursor adapter and set it to display
    SimpleCursorAdapter notes = 
        new SimpleCursorAdapter(this, R.layout.time_text_row, mTimeNotesCursor, from, to);

    setListAdapter(notes);
   // SimpleCursorAdapter notesTime = 

       //new SimpleCursorAdapter(this, R.layout.time_text_row, mTimeNotesCursor, fromTime, toTime);
        //setListAdapter(notesTime);
}

STACK TRACE

01-04 09:47:30.260: E/AndroidRuntime(273): FATAL EXCEPTION: main
01-04 09:47:30.260: E/AndroidRuntime(273): java.lang.RuntimeException: Unable to start activity ComponentInfo{www.freshapp.com.wherewhen.html/www.freshapp.com.wherewhen.html.TimeViewer}: android.database.sqlite.SQLiteException: near "Table": syntax error: , while compiling: SELECT * FROM wwTable mLat INNER JOIN wwTimeTable _id ON wwTable._id=wwTimeTable.mName WHERE Table._id=wwTimetabel.mForeign
01-04 09:47:30.260: E/AndroidRuntime(273):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
01-04 09:47:30.260: E/AndroidRuntime(273):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
01-04 09:47:30.260: E/AndroidRuntime(273):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
01-04 09:47:30.260: E/AndroidRuntime(273):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
01-04 09:47:30.260: E/AndroidRuntime(273):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-04 09:47:30.260: E/AndroidRuntime(273):  at android.os.Looper.loop(Looper.java:123)
01-04 09:47:30.260: E/AndroidRuntime(273):  at android.app.ActivityThread.main(ActivityThread.java:4627)
01-04 09:47:30.260: E/AndroidRuntime(273):  at java.lang.reflect.Method.invokeNative(Native Method)
01-04 09:47:30.260: E/AndroidRuntime(273):  at java.lang.reflect.Method.invoke(Method.java:521)
01-04 09:47:30.260: E/AndroidRuntime(273):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-04 09:47:30.260: E/AndroidRuntime(273):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-04 09:47:30.260: E/AndroidRuntime(273):  at dalvik.system.NativeStart.main(Native Method)
01-04 09:47:30.260: E/AndroidRuntime(273): Caused by: android.database.sqlite.SQLiteException: near "Table": syntax error: , while compiling: SELECT * FROM wwTable mLat INNER JOIN wwTimeTable _id ON wwTable._id=wwTimeTable.mName WHERE Table._id=wwTimetabel.mForeign
01-04 09:47:30.260: E/AndroidRuntime(273):  at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
01-04 09:47:30.260: E/AndroidRuntime(273):  at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91)
01-04 09:47:30.260: E/AndroidRuntime(273):  at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
01-04 09:47:30.260: E/AndroidRuntime(273):  at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:80)
01-04 09:47:30.260: E/AndroidRuntime(273):  at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:46)
01-04 09:47:30.260: E/AndroidRuntime(273):  at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
01-04 09:47:30.260: E/AndroidRuntime(273):  at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1345)
01-04 09:47:30.260: E/AndroidRuntime(273):  at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1315)
01-04 09:47:30.260: E/AndroidRuntime(273):  at www.freshapp.com.wherewhen.html.WWDatabase.fetchTime(WWDatabase.java:143)
01-04 09:47:30.260: E/AndroidRuntime(273):  at www.freshapp.com.wherewhen.html.TimeViewer.fillData(TimeViewer.java:57)
01-04 09:47:30.260: E/AndroidRuntime(273):  at www.freshapp.com.wherewhen.html.TimeViewer.onCreate(TimeViewer.java:41)
01-04 09:47:30.260: E/AndroidRuntime(273):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-04 09:47:30.260: E/AndroidRuntime(273):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
01-04 09:47:30.260: E/AndroidRuntime(273):  ... 11 more

I would love any help on this. I have been looking for some time now.

  • 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-27T23:10:58+00:00Added an answer on May 27, 2026 at 11:10 pm

    Your where clause references an object called Table which you haven’t got in your FROM clause. Also, there’s not much point in aliasing your tables if you’re not using the aliases..

    I’m guessing it should be:

    private final String MY_QUERY = "SELECT * FROM wwTable INNER JOIN wwTimeTable ON wwTable._id=wwTimeTable.mName WHERE wwTable._id=wwTimetable.mForeign"; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database schema where the convention for a foreign key's name is:
i have a proble, when insert something in foreign language into database. i have
I have a database that contains a date and we are using the MaskedEditExtender
I have a database table and one of the fields (not the primary key)
I am using Entity Framework from .NET 3.5 I have two tables with 0-1
I have a MySQL database holding hierarchical data using the Closure Table method. A
I have a query that, basically, says this: SELECT DISTINCT [DB_ID] FROM [TableX] WHERE
I am trying to import data from a large database. I have two tables
I have problems with a specific query when using the sqlite3_step function: SELECT DISTINCT
I'm using EF 4.1 and a database I didn't design. I have two tables

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.