change query for a join file

J

JRough

I need to change this query because I needed a join file
between company and car_owners.
There is a many to many between cars and owners for rental
purposes. One car could have more than one owner_company and one owner
could have more than one cars. So to get this same query with the
join file, what do I do? There are some more complicated queries
where I have to get all
the cars for one company but I thought I would start with this one
since I don't know what to
do with the join file. This query should get all the car_id's for
each owner even ones that were
owned by more than one company.

Select car_o.car_id AS car_id, co.comp_name AS comp_name,
car_o.start_date AS start_date,car_o.end_date AS end_date
from (MyDatabase.CAR_OWNER car_o
INNER JOIN MyDAtabase.COMPANY co)
where (car_o.comp_id=co.comp_id);

company:
companyId
company_type [owner, lessee]

company_car_join:
carID
companyID

car_owner:
carOwnerID
start_date
end_date


car:
carID
carMarkID

tia,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top