sql - MySQL: left join exclusion -
i'm struggling mysql request cannot seem find right syntax. design of database pretty simple: have table applicant, table internship , table application. when applicant applies internship, insert row application table containing 2 foreign keys linking applicant , internship.
question: how can list of internships applicant has not applied already, knowing applicant's id?
so far: came query, that's not it:
select internship.* internship left join application on application.id_internship = internship.id_internship application.id_applicant null or application.id_applicant <> 42 group application.id_internship
any appreciated. have day.
you should use condition applicant id in join , use =
operator, joined records ones connected applicant, filter out internships join has match:
select internship.* internship left join application on application.id_internship = internship.id_internship , application.id_applicant = 42 application.id_applicant null
there no need group query, each internship occurs once in result.
Comments
Post a Comment