简体   繁体   中英

mySQL how do you do a chain of join?

在此处输入图片说明

Hi! I am trying to figure out how to do a join in multiple steps in the same line of code. This is what i got so far, but I get an error 1064.

select * from jbcity
join jbsupplier on jbsupplier.city = jbcity.name where jbcity.state = "Mass"
join jbsupply on jbsupply.supplier = jbsupplier.id
join jbparts  on jbparts.id = jbsupply.part;

Try this:

select * from jbcity
join jbsupplier on jbsupplier.city = jbcity.name 
join jbsupply on jbsupply.supplier = jbsupplier.id
join jbparts  on jbparts.id = jbsupply.part where jbcity.state = 'Mass';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM