Skip to main content
Participating Frequently
May 27, 2011
Question

Create a query that finds results from two fields in separate tables

  • May 27, 2011
  • 1 reply
  • 383 views

Hi

I am trying to create a query where I can get results from two separate tables.   I have two tables "recruiters" and "jobs".  In both of these tables I have a field called "RecruiterID" where everytime a recruiter registers it creates a unique number (auto increment) in the RecruiterID field.  Then whenever a recruiter posts a job it inserts the RecruiterID into the Jobs Table in the RecruiterID field.  I have created a recordset with the following query:-

SELECT *

FROM jobs, recruiters

WHERE jobs.RecruiterID = recruiters.RecruiterID

the purpose of this query is to find all jobs that a recruiter is currently advertising but when i bind the recordset details into the table where i want to show all a specific recruiters jobs it brings up all the jobs with an id over 0.

I think i need to specify which recruiter i am searching for but i have been working of this for ages and my brain seems to have died!!!  Is there a way of finding out for instance if it was looking at JobID 17 how do i find all the other jobs that that specific recruiter is looking for?  would i need to create some sort of variable in the recordset?

ANY help for the brain-dead would be really appreciated

This topic has been closed for replies.

1 reply

Participating Frequently
May 27, 2011

>would i need to create some sort of variable in the recordset?

No. It's just basic SQL

SELECT *

FROM jobs, recruiters

WHERE jobs.RecruiterID = recruiters.RecruiterID

AND

recruiters.RecruiterID in (Select RecruiterID from jobs where  JobID = 17)

Laura76Author
Participating Frequently
May 27, 2011

Hi

The job number would not always be 17 though - the job number would depend what job a jobseeker clicks on.

Participating Frequently
May 27, 2011

>The job number would not always be 17 though - the job number would depend what job a jobseeker clicks on.

Of course. You simply need to substitute that hardcoded value with a variable.