mysql - SQL puzzle very close to solving but can't get parentid -


i need bit of help/direction how write sql query using following information:

please click here sql table

the question is:

the manager see of cars in showroom , price, in following form: [make] [model] – £[price] e.g. “vw golf - 3000”. write sql query satisfy this.

i can't seem parentcarid match id in car table , closest ive gotten making happen.

select  car.makecode, car.name, showroom.price car inner join showroom on car.id=showroom.carid showroom.carid = “2” or showroom.carid = “5” or showroom.carid = “8”; 

but still doesn't display model name displays model code , i'm thinking need somehow join car table answer.

so want display in way :

model    make     price  ford fiesta   - 4000     vw  golf     - 3000     peugeot 307   -5000 

you try query:

select c.id, p.name, c.name, s.price car c       inner join car p on p.id = c.parentcarid      inner join showroom s on s.carid = c.id 

Comments