Q: Fetching MySQL data going through multiple tables I'm wanting to do the following:
Select everything from product that matches the value of type_id from both tables product and system_type. Then with those matched results, match cat_id from both tables system_type and system_cat and then refine the final result where cat_type = 0 from the system_cat table.
Current SQL seems to have a syntax error:
SELECT * FROM product
JOIN system_type
    USING (type_id)
JOIN system_cat
    USING (cat_id)
WHERE cat_type = 0

What else I've tried:
SELECT * FROM product
JOIN system_type
    USING system_type.type_id = product.type_id
JOIN system_cat
    USING system_type.cat_id = system_cat.cat_id
WHERE system_cat.cat_type = 0


A: Try this. You may need to explicitely type out the columns you need
SELECT * FROM product as pr 
INNER JOIN system_type as st
    ON st.type_id = pr_id
INNER JOIN system_cat as sc
    ONH st.cat_id = sc.cat_id
WHERE sc.cat_type = 0


A: Syntax changes when using table_name.column method. Use ON and not USING.
SELECT * FROM product
JOIN system_type
    ON system_type.type_id = product.type_id
JOIN system_cat
    ON system_type.cat_id = system_cat.cat_id
WHERE system_cat.cat_type = 0

