p.slugUrl AS resultslug, p.id, m.slugUrl, m.categoryParent, pa.pageId, pa.categoryId from tcs_pagecontents as p,tcs_pageassociation as pa, tcs_menucategory_site as m where p.id=pa.pageId and pa.categoryId=m.id ;
这将返回一个具有以下结构的表(假设此表为P)
resultslug
id
slugUrl
categoryParent
pageId
categoryId
此外,我想将这个结果表连接到另一个表,其中P.categoryParent = T.id,这里T是另一个表,我想获取以下coloumn名称
P.resultslug
P.id
P.slugUrl
P.categoryParent
P.pageId
P.categoryId
T.slugUrl
where P.categoryParent = T.id;
我在这里变得空白。任何想法将不胜感激。提前谢谢。
答案 0 :(得分:2)
只需像其他表一样加入该表。
select p.slugUrl AS resultslug, p.id, m.slugUrl, m.categoryParent, pa.pageId, pa.categoryId, T.slugURL
from tcs_pagecontents as p
join tcs_pageassociation as pa on p.id=pa.pageId
join tcs_menucategory_site as m on pa.categoryId=m.id
join another_table T on m.categoryParent = T.id;