Asp.net listview中的sql查询

Asp.net listview中的sql查询,asp.net,sql-server-2008,Asp.net,Sql Server 2008,您好,我想执行这两个查询并在列表视图中同时显示结果。如何在一个select命令中执行此查询: 我的sql查询: Shareholder details: Select inlt_parentcompanyid,inlt_effectinterest,inlt_sharetype,inlt_shares from InterestLogTable where inlt_childcompid=5 Subsidiary details: select inlt_childcom

您好,我想执行这两个查询并在列表视图中同时显示结果。如何在一个select命令中执行此查询:

我的sql查询:

Shareholder details:
   Select inlt_parentcompanyid,inlt_effectinterest,inlt_sharetype,inlt_shares from InterestLogTable where inlt_childcompid=5
    Subsidiary details:
    select inlt_childcompid,inlt_effectinterest,inlt_sharetype,inlt_shares from InterestLogTable where inlt_parentcompanyid =5
我的asp.net列表视图:

Shareholder details:
                    <td><%#Eval("owner_parentCompanyId")%>&nbsp;</td> 
                    <td><%#Eval("owner_sharetype")%>&nbsp;</td>
                    <td><%#Eval("owner_effectinterest")%>&nbsp;</td>   
                    <td><%#Eval("owner_deemedinterest")%>&nbsp;</td>                 
                    <td><%#Eval("owner_shares")%>&nbsp;</td> 

Sunsidiary details:
                    <td><%#Eval("owner_childCompanyId")%>&nbsp;</td> 
                    <td><%#Eval("owner_sharetype")%>&nbsp;</td>
                    <td><%#Eval("owner_effectinterest")%>&nbsp;</td>   
                    <td><%#Eval("owner_deemedinterest")%>&nbsp;</td>                 
                    <td><%#Eval("owner_shares")%>&nbsp;</td> 
股东详细信息:
日食详情:

要在同一个listview中使用它,您的查询应该返回一个包含两个表中的列的singl结果集。为此,你必须内在地结合。像这样

 Select inlt_parentcompanyid,inlt_effectinterest,inlt_sharetype,inlt_shares,inlt_childcompid,inlt_effectinterest,inlt_sharetype,inlt_shares from InterestLogTable INNER JOIN InterestLogTable ON InterestLogTable.intl_parentcompanyid=InterestLogTable.inlt_parentcompanyid where 
InterestLogTable.intl_parentcompanyid=5

当然,您需要使用tableName.coulumnName来处理两个表中相同的列名称