0

I have three tables which I have to join. I'm not a good SQL writer. Can please sombody help me to prepare this using joins:

branches
-----------------------------------------
branch_id | branch_name | branch_address
-----------------------------------------

branch_services
-------------------------------
bs_id | branch_id | service_id
-------------------------------

services
--------------------------
service_id | service_name
--------------------------

I need to select * from the branches table and service_names related to each branch.

2
select 
    b.*,
    s.service_name
from 
    branches b,
    branch_services bs,
    services s
where
    b.branch_id=bs.branch_id 
    and bs.service_id=s.service_id

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.