Asking Help on SQLITE 3 QUERY with Foreign Key
Publicado: 12 Feb 2021 10:35
Hello i am asking for help regarding getting data from database with 2 foreign keys i am stuck in getting data in INNER JOIN
my query is i believe works fine but i need to print the 2 students who will be playing in the quiz.. every quiz there is 2 student who will join.
i have table QuizB with 2 foreign keys in Student Table
table QuizB
QuizB_ID PK
Student1_ID FK
Student2_ID FK
table Student
StudentID PK
StudentFirstName
StudentLastName
for row in db:nrows("SELECT * FROM QuizB Q INNER JOIN Student S1 ON Q.Studen1_ID = S1.StudentID INNER JOIN Student S2 ON Q.Student2_ID = S2.StudentID")
i = Grid.GetRowCount("Grid1");
Grid.InsertRow("Grid1", -1, false);
Grid.SetCellText("Grid1", i, 0, row.QuizB_ID, true);
Grid.SetCellText("Grid1", i, 1, "["..i.."] "..row.StudentFirstName.." "..row.StudentLastName.." || "..row.StudentFirstName.." "..row.StudentLastName, true);
end
i need to get the 2 student in the QuizB table
as of now the result is the same student name
example
[1.] WILL SMITH || WILL SMITH
instead of
[1.] JOHN DOE || WILL SMITH
thank you for any help.
my query is i believe works fine but i need to print the 2 students who will be playing in the quiz.. every quiz there is 2 student who will join.
i have table QuizB with 2 foreign keys in Student Table
table QuizB
QuizB_ID PK
Student1_ID FK
Student2_ID FK
table Student
StudentID PK
StudentFirstName
StudentLastName
for row in db:nrows("SELECT * FROM QuizB Q INNER JOIN Student S1 ON Q.Studen1_ID = S1.StudentID INNER JOIN Student S2 ON Q.Student2_ID = S2.StudentID")
i = Grid.GetRowCount("Grid1");
Grid.InsertRow("Grid1", -1, false);
Grid.SetCellText("Grid1", i, 0, row.QuizB_ID, true);
Grid.SetCellText("Grid1", i, 1, "["..i.."] "..row.StudentFirstName.." "..row.StudentLastName.." || "..row.StudentFirstName.." "..row.StudentLastName, true);
end
i need to get the 2 student in the QuizB table
as of now the result is the same student name
example
[1.] WILL SMITH || WILL SMITH
instead of
[1.] JOHN DOE || WILL SMITH
thank you for any help.