SELECT * FROM (select a.*,(select tname from userinfo where a.uid=userinfo.id)as tname,(select cname from company where a.cid=company.id)as cname,(select pactsub from pactsub where pactsub.id=a.pactsub) as psub from companypact a where " + Request.QueryString["keyword"].ToString() + " like'%" + Request.QueryString["key"].ToString() + "%' ) AS T
再加一次子查询试试?

解决方案 »

  1.   

    改成连接试试select a.*,b.*,c.*
    from companypact as a 
    innner join userinfo  as b on a.uid=b.id
    innner join company  as c on a.cid=c.id
    inner join pactsub as d on a.pactsub=d.id
    where " + Request.QueryString["keyword"].ToString() + " like'%" + Request.QueryString["key"].ToString() + "%' 
      

  2.   

    我有点怀疑
    select cname from company where a.cid=company.id
    返回的值不唯一。