有人请告诉我 SQL 查询以获得结果....
谢谢!
从上面的两个表中,我想从其中的每个表中获取Photo
, Name
,即Id of max(id)
Table-A
category_id
parent_id
Table-B
1
1005 E Byte Apple 3
1002 B Byte Banana 5
1007 G Byte Orange 6
1011 K Byte Mango 7
有人请告诉我 SQL 查询以获得结果....
谢谢!
从上面的两个表中,我想从其中的每个表中获取Photo
, Name
,即Id of max(id)
Table-A
category_id
parent_id
Table-B
1
1005 E Byte Apple 3
1002 B Byte Banana 5
1007 G Byte Orange 6
1011 K Byte Mango 7
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
试试下面的;
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)