All pastes #244901 Raw Edit

Anonymous

public text v1 · immutable
#244901 ·published 2006-11-10 10:46 UTC
rendered paste body
I'm writing a query that'll give me a match on the teachers and jobs table. But that won't show up any matches that i've already sent, and therefore have stored in the sent_match table... 

Tables look liket this ...

TEACHERS
id name location status arrival
1...tom.....1..........1.........dec
2...kris.....2..........1.........sep
3...harry...2..........1.........sep

JOBS
id school location arrival status
6...harries....3.........dec......1
7...kims.......2.........sep.......1
8...leaders....2.........sep......1

Now, from here matching the TEACHERS to the JOBS based on approx arrival (give or take a few days) and upon location is easy. But if I send a teacher to a school. Then I'd like it recorded in my sent match table.

So Harry matches with leaders school, so I'd like to put them both in SENT_MATCH

SENT_MATCH
teacher_id school_id
...3..............8

Now, my query needs to pull out all the matches from the TEACHERS and JOBS table. But it needs to disregard any matches that have already been put into SENT_MATCH...

So basically ... match
kris with kims
kris with leaders
harry with kims

BUT not harry with leaders as I've already sent that offer to Harry...

This is probably pretty easy. But I've tried it numerous different ways and it always comes out wrong.