I have a table such as in the example below. I have a web form with 2 grids. The first one shows parent details and the second grid shows the child details. User enters an id inside a textbox and searches for id and the grids are populated.
If user enters id=101 then in the parent grid the row with fundid=101 is shown and the second grid is populated with fundid=762 and 567.
If user enters id 567 then I want the first grid to show parent details where fundid =101 and the secode gridview to show fundid=567.
Not sure how to write the query to populate the first grid`
Thought if something like this:
create table #tmpFund (fundid int, fundname varchar (50),parentid int) insert into #tmpFund values(762,'Phoenix ltd', 101) insert into #tmpFund values(567,'Phoenix ', 101) insert into #tmpFund values(101,'Phoenix Canada ltd', 0) insert into #tmpFund values(811,'Orlando ltd', 234) insert into #tmpFund values(345,'Orlando ', 234) insert into #tmpFund values(67,'Orlando ', 234) insert into #tmpFund values(234,'Orlando Canada ltd', 0) declare @mispar_kupa_av int set @mispar_kupa_av=(select mispar_kupa_av from gemelkupot where kupaid=101) if @mispar_kupa_av>0 begin select * from #tmpFund where fundid=@mispar_kupa_av end