有人请告诉我SQL查询以获得结果....
谢谢!
从上面的两个表格中,我想从[{1}}获取Photo
的{{1}},Name
,Id of max(id)
Table-A
category_id
} parent_id
中的Table-B
即
1
答案 0 :(得分:2)
select a.id,a.name,a.photo,b.category_name,b.category_id
from table-A a join table-B s ON a.category_id = b.category_id
where parent_id = 1
答案 1 :(得分:1)
尝试以下内容;
Select TBLA.ID, TBLA.Name, TBLA.Photo, TBLB.Category_Name, TBLB.Category_ID
From [table-B] TBLB
Inner Join [table-a] TBLA On TBLA.Category_ID = TBLB.Category_ID
Where TBLB.Parent_ID = 1
And TBLA.ID = (Select Max(ID)
From [table-a]
Where Category_ID = TBLB.Category_ID)