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.

database design

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

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -