This may be a broad questions, but in my current project I have opened up 3 tables within a database, and being able to read the data that is only related to the specific ID that I choose. for example I have the user create their school classes, then enter in each weight category for the class they are creating. I want to be able to read only the information related to the class that was clicked on in the database, but I don't know the way to really do that.
These are the tables and fields I have set up. Let me know if more information is needed. Thank you in advance.
public static final String TABLE_NAME = "class_table";
public static final String WEIGHT_TABLE = "weight_table";
public static final String WORK_TABLE = "work_table";
db.execSQL("create table " + TABLE_NAME +
"(ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT)");
db.execSQL("create table " + WEIGHT_TABLE +
"(ID INTEGER PRIMARY KEY AUTOINCREMENT, WEIGHT_NAME TEXT,"+
" PERCENT REAL, CLASS_ID INTEGER, " +
"FOREIGN KEY(CLASS_ID) REFERENCES " +TABLE_NAME+"(ID)");
db.execSQL("create table " + WORK_TABLE +
"(ID INTEGER PRIMARY KEY AUTOINCREMENT, WORK_NAME TEXT, "+
"POINTS_EARNED INTEGER, MAX_POINTS INTEGER, " +
"WEIGHT_ID INTEGER, CLASS_ID, FOREIGN KEY(WEIGHT_ID) REFERENCES "+
WEIGHT_TABLE+"(ID), FOREIGN KEY(CLASS_ID) REFERENCES "+
TABLE_NAME+"(ID)");
Aucun commentaire:
Enregistrer un commentaire