select b.truename,b.tel1,a.intime,a.cvid,b.comfrom,(select company from work where cvid=b.id)as company,(select tagname from cvtag where cvid=b.id)as tag from cvsession a,cvresume b where a.cvid =b.id and a.xmid in(select id from xm)我想以cvsession 为中心,返回他的所有行数,但是这里报错

解决方案 »

  1.   


    select b.truename,b.tel1,a.intime,a.cvid,b.comfrom,(select company from work where cvid=b.id)as company,(select tagname from cvtag where cvid=b.id)as tag from cvsession a,cvresume b where a.cvid =b.id and a.xmid in(select id from xm)中间两个子查询改成Left Join
      

  2.   

    不是自己写的SQL 那么长还真难看懂
      

  3.   

    select b.truename,b.tel1,a.intime,a.cvid,b.comfrom,
    (select company from work where cvid=b.id) as company,
    (select tagname from cvtag where cvid=b.id) as tag 
    from 
    cvsession a,
    cvresume b 
    where a.cvid =b.id and a.xmid in(select id from xm)
    select company from work where cvid=b.id --这有多少条数据?
    select tagname from cvtag where cvid=b.id --这个有多少条数据?单独查一下
      

  4.   

    他们的数据都是不一样的,我想以cvsession 为主,不管work有没有cvid都显示cvsession表的条数
      

  5.   

    SELECT  b.truename ,
            b.tel1 ,
            a.intime ,
            a.cvid ,
            b.comfrom ,
            ( SELECT    MAX(company)
              FROM      work
              WHERE     cvid = b.id
            ) AS company ,--你这里返回的是一个集合,使用聚合或者只返回一个值
            ( SELECT    MAX(tagname)
              FROM      cvtag
              WHERE     cvid = b.id
            ) AS tag --此处错误同上
    FROM    cvsession a
            LEFT JOIN cvresume b ON a.cvid = b.id --改用左连接
    WHERE   a.xmid IN ( SELECT  id
                        FROM    xm )