Roxx
Roxx

Reputation: 3986

mysqli inner join: data not exist in other table

I have 3 tables and I am using inner join to get the data from table.

 select b.pic,b.fname,b.lname, a.job_id, a.uid, a.job_title, a.description, a.city, a.position, 
        a.salary, a.looking_for,a.website,a.date
   from job_posting a 
  inner join users b
  inner join job_applied c on a.uid = b.uid and b.uid = c.uid
  where c.job_id IS NULL and c.uid IS NULL and a.looking_for = 'student'

Above query is not returning any data. It's empty.

Let me explain the table.

job_posting - Contain job information.
users - contain user information who posted the job.
job_applied - contain user has applied for the jobs.

So, I want to get the jobs those are not applied. In Job_paplied table I have job_id and uid.

Upvotes: 2

Views: 121

Answers (1)

Mayank Pandeyz
Mayank Pandeyz

Reputation: 26258

Instead of inner join try LEFT JOIN like:

select b.pic,b.fname,b.lname, a.job_id, a.uid, a.job_title,a.description,a.city, a.position, 
a.salary, a.looking_for,a.website,a.date from job_posting a  
LEFT JOIN users b  on a.uid = b.uid 
LEFT JOIN job_applied c  on b.uid = c.uid
where c.job_id IS NULL  and a.looking_for = 'student'

and try again.

Upvotes: 2

Related Questions