I want to select result in sqlite from multiple tables with multiple foreign keys, I tried JOIN but it did not work that well; for example :
a table for STUDENT :
CREATE TABLE STUDENT (
STUDENT_NAME TEXT NOT NULL,
STUDENT_NUMBER INTEGER PRIMARY KEY NOT NULL,
STUDENT_ADDRESS TEXT NOT NULL
);
and a table for EXAMS :
CREATE TABLE EXAMS(
EXAM_CODE INTEGER PRIMARY KEY NOT NULL,
EXAM_SUBJECT TEXT NOT NULL,
EXAM_LOCATION TEXT NOT NULL
);
and a table called WROTE_EXAM to get the information for students who wrote a specific exam
CREATE TABLE WROTE_EXAM (
STUDENT_NUMBER INTEGER NOT NULL,
EXAM_CODE INTEGER NOT NULL,
DATE DATE NOT NULL,
FOREIGN KEY(STUDENT_NUMBER) REFERENCES STUDENT(STUDENT_NUMBER),
FOREIGN KEY(EXAM_CODE) REFERENCES EXAMS(EXAM_CODE));
this is a sample data inserted into tables :
STUDENT_NAME : John
STUDENT_NUMBER: 123456789
STUDENT_ADDRESS : 10th street
EXAM_CODE: 123
EXAM_SUBJECT: One Subject
EXAM_LOCATION: Class
now, I want to :
a) output student names, exam codes and student location, who wrote the exam
b) output exam code, exam subject and exam location for student with ID : 123456789
thanks

SELECT DISTINCT STUDENT_NAME,EXAM_CODE,STUDENT_LOCATION FROM WROTE_EXAM,STUDENT JOIN EXAMS,STUDENTSnot sure how to join 3 tables together and get this information