我有三张桌子
现在我想获取这样的数据:
treat_Name sub_Name cat_name where subID = 1001
请帮我解决这个问题。
答案 0 :(得分:0)
您只需JOIN
三个表:
SELECT c.treat_Name,
b.sub_Name,
a.cat_name
FROM tbl_category a,
tbl_subcategory b,
tbl_treatment c
WHERE a.c_id = b.catid
AND b.c_id = c.subid
AND c.subid = 1001
答案 1 :(得分:0)
使用INNER JOIN来解决这个问题
SELECT c.treat_Name,
b.sub_Name,
a.cat_name
FROM ((tbl_category a INNER JOIN tbl_subcategory b
ON a.c_ID = b.catID)
INNER JOIN tbl_treatment c
ON b.catID = c.subID)
WHERE c.subID = 1001
答案 2 :(得分:0)
SELECT c.treat_Name,
b.sub_Name,
a.cat_name
FROM tbl_treatment c inner join tbl_subcategory b
on b.c_id = c.subid
inner join
tbl_category a
on a.c_id = b.catid
where c.subid = 1001