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
This:
Should be
With the comma it looks like another column.
Here is what I have:
So, to have this work with your set up
This may be enough.