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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:31:07+00:00 2026-06-05T18:31:07+00:00

I was making one table that have two foreign key to another tables. But

  • 0

I was making one table that have two foreign key to another tables. But still error in the query.

here the code :

    //inialitation attribute
    public static final String TABLE_MATRIKPENDAPAT = "tableMatrikPendapat";
    public static final String MATRIK_IDKRITERIA1 = "matrikIdKriteria1";
    public static final String MATRIK_IDKRITERIA2 = "matrikIdKriteria2";
    public static final String MATRIK_NILAI = "nilaiMatrik";

    //create query

    private static final String CREATE_TABLE_MATRIKPENDAPAT = "create table "
            + TABLE_MATRIKPENDAPAT + " ("
            + MATRIK_IDKRITERIA1 + " integer , FOREIGN KEY ("+ MATRIK_IDKRITERIA1 +") REFERENCES "
            + TABLE_KRITERIA + " ("+ KRITERIA_ID +"), " 
            + MATRIK_IDKRITERIA2 + " integer , FOREIGN KEY ("+ MATRIK_IDKRITERIA2 +") REFERENCES "
            + TABLE_KRITERIA + " ("+ KRITERIA_ID +"), "
            + MATRIK_NILAI + " integer not null);";

And the error said :

sqlite.SQLiteException: near "matrikIdKriteria2": syntax error

when i make it with with one foreign key, like here :

    private static final String CREATE_TABLE_MATRIKPENDAPAT = "create table "
    + TABLE_MATRIKPENDAPAT + " ("
    + MATRIK_IDKRITERIA1 + " integer , FOREIGN KEY ("+ MATRIK_IDKRITERIA1 +") REFERENCES "
    + TABLE_KRITERIA + " ("+ KRITERIA_ID +"), " 
    + MATRIK_NILAI + " integer not null);";

the error said :

sqlite.SQLiteException: near “nilaiMatrik”: syntax error

so I think, my problems there in query after the first foreign key.

what should the correct query ??
Please help me guys

  • 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-05T18:31:09+00:00Added an answer on June 5, 2026 at 6:31 pm

    This:

    integer , FOREIGN 
    

    Should be

    integer  FOREIGN 
    

    With the comma it looks like another column.

    Here is what I have:

       + BookTableMetaData.BOOK_USER_ID + " INTEGER REFERENCES "
       + UserTableMetaData.TABLE_NAME + "("
    + UserTableMetaData._ID + "),"
    

    So, to have this work with your set up

    MATRIK_IDKRITERIA1 + " integer REFERENCES "
    + TABLE_KRITERIA + " ("+ KRITERIA_ID +")
    

    This may be enough.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two rating/votes tables. One for user votes and stats and another for
If I have a table that has a primary key and a foreign key,
I have two tables with a many-to-one relationship. (Oracle) **Table: PARENT** Field: A (PK)
I am making simple connection between two table - first one called users has
I have two Postgres databases. In one I have two tables, each with about
I have two tables, one is for individuals and the other is for their
I have two tables(InnoDB) one with 15 million records and the other with 14
Okay, so let's say I have a mysql database table with two columns, one
Another basic Rails question: I have a database table that needs to contain references
Person has two similar tables, difference is that each person has only one record

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.