This is a discussion on Help with negative join syntax? within the MySQL forums, part of the Database Server Software category; --> Hi, Not sure if query syntax is germane here. If not please advise as to a group where I ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi, Not sure if query syntax is germane here. If not please advise as to a group where I could ask. I need to do a kind of join that I have not had to do before. I need to find records which exist only in one of two tables. Everyone has a record in `person` but not every person record has an attendant `contest_entry` record. I need to find records that exist in `person` but not in `contest_entry`. So I tried SELECT person.id, contest_entry.person FROM person, contest_entry WHERE person.datetime_added > '2007-11-27' AND person.id != contest_entry.person which got me 81,174,327 results as a factorial of the two sets. Who do I make this negative join? TIA!! jg |
| |||
| jerrygarciuh wrote: > Hi, > > Not sure if query syntax is germane here. If not please advise as to > a group where I could ask. > > I need to do a kind of join that I have not had to do before. I need > to find records which exist only in one of two tables. > > Everyone has a record in `person` but not every person record has an > attendant `contest_entry` record. I need to find records that exist > in `person` but not in `contest_entry`. > > So I tried > > SELECT person.id, contest_entry.person > FROM person, contest_entry > WHERE person.datetime_added > '2007-11-27' > AND person.id != contest_entry.person > > which got me 81,174,327 results as a factorial of the two sets. Who > do I make this negative join? > > TIA!! > > jg SELECT person.id, contest_entry.person FROM person LEFT JOIN contest_entry ON person.id = contest_entry.person WHERE person.datetime_added > '2007-11-27' AND contest_entry.person IS NULL |