我有这四个表:
Items_a (item_id, name, cat_id, sub_cat_id)
Items_b (id, name2, cat_id, sub_cat_id)
Category (cat_id, cat_name)
Sub_category (sub_cat_id, sub_name, cat_id)
我想加入这些表并尝试以下查询,但它不起作用:
SELECT * FROM(
SELECT * FROM(
SELECT * FROM items_c AS c
JOIN category as t ON c.cat_id=t.cat_id
) as ct
JOIN sub_category as s ON ct.sub_cat_id=s.sub_cat_id
) as cts
JOIN items_nc AS n ON cts.sub_cat_id=s.sub_cat_id
有人能帮助我吗?
答案 0 :(得分:0)
猜猜这就是你需要的,你可以指定列名列表而不是*
SELECT * FROM items_c c JOIN category t ON c.cat_id=t.cat_id
JOIN sub_category s ON ct.sub_cat_id=s.sub_cat_id
JOIN items_nc n ON cts.sub_cat_id=s.sub_cat_id
您可以进一步推荐THIS。
答案 1 :(得分:0)
参考此
SELECT *
FROM category c
INNER JOIN sub_category sc on c.cat_id = sc.cat_id
INNER JOIN item_a a on sc.sub_cat_id = a.sub_cat_id
INNER JOIN item_b b on sc.sub_cat_id = b.sub_cat_id
答案 2 :(得分:0)
试试这个:
<script> and </script>