How to join 4 table pls help me

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • govindpraveen
    New Member
    • Jul 2007
    • 1

    How to join 4 table pls help me

    I have 4 tables

    1)category fields -------id-----catrgory
    2)Manufacturer fields---------id--------manufacturer---------category_id--------------
    3) Models fields----------------id--------Model-------------------Manufacturer_id---------
    4)Products fields--------------id-----title-----description_mod el-------price--------model_id
    5)Details fields--------product_id-----name-----description-----volts----warranty--dimensions--



    i want to get the details of products as

    product_id-----name----description--volts----warranty--dimensions-----title----description_mod el--price--model--manufacturer---category--

    pls help its urgent i am new to mysql
  • mwasif
    Recognized Expert Contributor
    • Jul 2006
    • 802

    #2
    Please use the exact column names and table names (take care of case). You have used different case in table descriptions and the columns you needed.

    Code:
    SELECT det.*, prod.title, prod.description_model, prod.price, mod.model, man.manufacturer, cat.category FROM Details det 
    INNER JOIN Product prod ON det.product_id = prod.id 
    INNER JOIN Models mod ON prod.model_id = mod.id 
    INNER JOIN Manufacturer man ON mod.Manufacturer_id = man.id 
    INNER JOIN category cat ON man.category_id = cat.id
    BTW, these are 5 tables not 4:)

    Comment

    Working...