Avatar of tektnoutchou
tektnoutchou

asked on 

Parent-Child SQL

I have two table as below:
table.png1. Table1 : TblCategory
Field: catID, CatNameEng, CatNameKh, MainID, DateUpdate, UserId
This table contain Parent-Child. Field "MianID" is parent.
table1.png
below is result of parent-child query:
select tblcategory.catnameeng CateNameEng, down1.catnameeng Sub1, down2.catnameeng sub2
from TblCategory
 left outer join TblCategory as down1 on TblCategory.CatID=down1.MainID
 left outer join TblCategory as down2 on down1.catid=down2.mainid
 where TblCategory.MainID='0' and TblCategory.CatID >'0' 

Open in new window

table3.png
2. Table2 : TblTVCSpot
table2.png
How to get result as in excel

Thanks,
Chou
result.xlsx
Microsoft SQL Server

Avatar of undefined
Last Comment
tektnoutchou

8/22/2022 - Mon