/* Prepare the data */
CREATE TABLE Exam (
StudentID INT NOT NULL,
ExamID INT NOT NULL,
Mark INT,
IfPassed SMALLINT,
Comments VARCHAR(255)
)TYPE = InnoDB;
/* Insert data for testing */
INSERT INTO Exam (StudentID,ExamID,Mark,IfPassed,Comments) VALUES (1,1,55,1,'Java Test');
INSERT INTO Exam (StudentID,ExamID,Mark,IfPassed,Comments) VALUES (1,2,73,1,'C# Test');
INSERT INTO Exam (StudentID,ExamID,Mark,IfPassed,Comments) VALUES (2,3,44,1,'JavaScript Test');
/* Real command */
SELECT StudentID, Mark, Comments FROM Exam
WHERE ExamID = 1 AND IfPassed = 1;
|