我正在制作一个表,该表有两个外键到另一个表。但是查询中仍然有错误。
这里的代码:
//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);";
错误说:
sqlite.SQLiteException: near "matrikIdKriteria2": syntax error
当我用一个外键制作它时,就像这里:
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);";
错误说:
sqlite.SQLiteException:靠近“nilaiMatrik”:语法错误
所以我认为,我在第一个外键之后的查询中存在问题。
正确的查询应该是什么?请帮帮我