SELECT Course.courseID,courseName,courseInstructor,if(103 in (select studentID from studentLink s where studentID=103 and s.courseID=Course.courseID),103,NULL) as ID from Course;
There must be a better solution, but I'm too tired. Have a look at the EXISTS clause in select statements.