mysql - Inner joining on more than 2 tables -
i have 5 tables need query from, , unsure how this. considering using multiple inner joins, getting thrown lots of errors.
here example of want do:
tables:
customer id name state hotelid 1 george w.a 1 2 franklin n.s.w 2 bus id make 1 hino 2 mercedes 3 leyland hotel id name 1 hyatt 2 sebel tour id tourname busid 1 japan 1 2 america 1 3 austria 2 tour-custlink id tourid custid 1 1 1 2 2 2 3 3 3
let's query list names, state of customers stayed @ hyatt , went on hino buses, how go doing this?
the tables not working with, i'd prefer in example this, , there way code add.
something ...
select c.name, c.state tourcustlink tcl inner join customer c on tcl.custid = c.id inner join hotel h on c.hotelid = h.id inner join tour t on tcl.tourid = t.id inner join bus b on t.busid = b.id h.name = 'hyatt' , b.make = 'hino'
but beware not optimised ... bit premature ... 8-)
Comments
Post a Comment