I have two tables all_jobs and jobs_applied. Problem is I want to get the list of jobs from all_jobs table. At the moment I have this query but it is only giving me common records from both table.
SELECT b.uid
, a.jobtitle
, a.job_id
FROM job_posting a
left
join job_applied b
on a.job_id = b.job_id
Where b.uid != 10 and disable=0 and draft =0
Edit
in job_posting table there are 24 records. in job_applied table there are 2 records. Both table have job_id field. When I execute the query I am expecting 23 records because one record is common in both table. But I am getting single record.
I have checked this question. What's the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN and FULL JOIN? but not sure how can I use it in my situation.
Edit 2 (table structure)
job_posting
job_id,
title,
skills,
post_date
job_applied
id,
job_id,
uid,
apply_date
What I am trying to achieve: I want to get the list of records from job_posting table but those records shouldn't be exist in job_applied table with specific uid
. So, it means i will have to add two things in where clause one for uid
and another one for job_id
.
I also tried below query but it is returning 0 records.
SELECT
a.jobtitle
, a.job_id
FROM job_posting a
left
join job_applied b
on a.job_id = b.job_id
Where (b.job_id is null and a.disable=0 and a.draft =0 and b.uid !=10)
Edit 3
I am using this query now and it is returning correct result.
Select a.jobtitle, a.job_id from job_posting a where
a.job_id not in (select b.job_id from job_applied b WHERE b.uid=1)
AND a.disable=0 AND a.draft =0
Let me know if I am doing anything wrong.