-2

I've problems in joining 9 mysql tables for my sample jobsite project. First i'm new to mysql joins and i have done database normalization.

My tables are:

  1. Job jid |title |salary | descr | req | duties

  2. Location | lid |county

  3. job_location | jid | lid

  4. contract | coid | terms

  5. job_contract | lid |lid

  6. company | cid | name

  7. job_company | cid | jid

  8. sector | sid | type

  9. job_sector | jid | sid

Now i need a query to get the following list of job details: title |salary | descr | req | duties |county | terms | company_name | job_location

The following code displays jobs location.

SELECT county 
FROM location 
         JOIN job_location ON job_location.lid = location.lid 
   INNER JOIN job          ON job.jid = job_location.jid;

Any assistance will be appreciated.

RiggsFolly
  • 89,708
  • 20
  • 100
  • 143
cheruiyot
  • 41
  • 1
  • 6
  • 1
    The same way you do it for 3 tables, just keep on coding joins – RiggsFolly Mar 04 '16 at 15:04
  • 1
    It is not clear from your question that you have all the required foreign keys in all the tables. If you are waiting for somone to code it for you you had better describe you database structure **a lot better than you have** – RiggsFolly Mar 04 '16 at 15:09

1 Answers1

0

This query might help except 'terms' field bcoz there is no mapping from contract table to any other tables.

select title,salary,descr,req,duties,
       county,name as comapny_name,job_location 
from job j 
    join job_location jl on j.jid=jl.jid 
    join location l on jl.lid=l.lid 
    join job_company jc on jc.cid=j.jid 
    join company c on c.cid=jc.cid
RiggsFolly
  • 89,708
  • 20
  • 100
  • 143
Ramesh
  • 32
  • 1
  • 6
  • How can you possibly know all those field names from the question? Is this one student helping another student with the same homework? Both from the same class? – RiggsFolly Mar 04 '16 at 15:12
  • He has mentioned clearly what all fields he required, By seeing his requirement , I answered – Ramesh Mar 04 '16 at 15:19