I have two tables: job_postings
and job_apply
. If the user applies to a job, it will inserted into the job_apply table. Now after page reload, I would like to show the user all the jobs except the one he just applied to. How can I accomplish this?
this is the job_apply table: job_id, user_id, last_apply_date
this is the job_postings table job_id, user_id, job_title, job_description, job_wage, job_child_count, job_date, job_time_from, job_time_to, add_inserted
I tried this:
SELECT tbl_users.user_id AS poster_id, userFirstName, userLastName, job_apply.job_id, job_postings.user_id, job_apply.user_id, job_title, job_description, job_wage, job_child_count, job_date, job_time_from, job_time_to, add_inserted,
DATE_FORMAT(add_inserted,'%d %b %Y, at %T') AS add_inserted
FROM job_postings
JOIN tbl_users ON job_postings.user_id = tbl_users.user_id
JOIN job_apply ON job_postings.job_id = job_apply.job_id
WHERE job_apply.job_id = job_postings.job_id
AND job_apply.user_id = 94
ORDER BY add_inserted DESC;
EDIT
update query
SELECT tbl_users.user_id AS poster_id, userFirstName, userLastName, job_postings.job_id, job_postings.user_id, job_apply.user_id, job_title, job_description, job_wage, job_child_count, job_date, job_time_from, job_time_to, add_inserted,
DATE_FORMAT(add_inserted,'%d %b %Y, at %T') AS add_inserted
FROM job_postings
JOIN tbl_users ON job_postings.user_id = tbl_users.user_id
LEFT JOIN job_apply ON job_postings.job_id = job_apply.job_id
AND job_apply.user_id = 83
GROUP BY job_postings.job_id
ORDER BY add_inserted DESC
EDIT 3
So i used this:
SELECT tbl_users.user_id AS poster_id, userFirstName, userLastName, job_postings.job_id, job_postings.user_id, job_apply.user_id, job_title, job_description, job_wage, job_child_count, job_date, job_time_from, job_time_to, add_inserted,
DATE_FORMAT(add_inserted,'%d %b %Y, kell %T') AS add_inserted
FROM job_postings
JOIN tbl_users ON job_postings.user_id = tbl_users.user_id
JOIN (SELECT * FROM job_apply WHERE job_id IS NOT NULL) job_apply ON job_postings.job_id = job_apply.job_id
WHERE job_apply.user_id = 94
This shows me the rows where user has applied, but I would like to get the values where user has NOT applied to. Any suggestions?