P
philipdowling
Hi All
Total newbie here so apologies in advance for silly question.
I am working with a mysql database.
In this database I have 2 tables (well more than that but thats not
important), these being; "tbl_jobs" and "tbl_keywords".
Each job has one to many keywords associated.
Each job has a job_id.
Each of the keywords is associated to a job by referencing the job_id.
What I want to be able to do is to pass in multiple keywords, and
select only jobs which have all of these keywords.
I thought this sounded easy but then realised that I cannot just use a
straight AND i.e:
SELECT * from tbl_jobs
INNER JOIN tbl_keywords
ON tbl_jobs.job_id = tbl_keywords.job_id
WHERE tbl_keywords.keyword = 'full-time' AND tbl_keywords.keyword=
'pension'
as this is attempting to look for a keyword which is both equal to
"full-time" and equal to "pension".
This is obviously going to return 0 rows as it is impossible for the
keyword "pension" to also be equal to "full-time"?
I hope this makes sense?
So can anyone point me in the right direction as to how to tackle
this?
Thanks
Total newbie here so apologies in advance for silly question.
I am working with a mysql database.
In this database I have 2 tables (well more than that but thats not
important), these being; "tbl_jobs" and "tbl_keywords".
Each job has one to many keywords associated.
Each job has a job_id.
Each of the keywords is associated to a job by referencing the job_id.
What I want to be able to do is to pass in multiple keywords, and
select only jobs which have all of these keywords.
I thought this sounded easy but then realised that I cannot just use a
straight AND i.e:
SELECT * from tbl_jobs
INNER JOIN tbl_keywords
ON tbl_jobs.job_id = tbl_keywords.job_id
WHERE tbl_keywords.keyword = 'full-time' AND tbl_keywords.keyword=
'pension'
as this is attempting to look for a keyword which is both equal to
"full-time" and equal to "pension".
This is obviously going to return 0 rows as it is impossible for the
keyword "pension" to also be equal to "full-time"?
I hope this makes sense?
So can anyone point me in the right direction as to how to tackle
this?
Thanks