av_accounts_main 
av_member 
两个表都有哪些字段,你现在想做的是什么操作,你直接说意图,这样大家才能明白你的意思,同时也好为你修正你的SQL语句

解决方案 »

  1.   

    我要把av_accounts_main 中的会员的编号属于manager_id 部门的记录数查出来,,会员是是属于av_member表的一个部门manager_id 
    请大家帮忙
      

  2.   

    select @no =  @no
          select @center =  @member_idselect @record_count=count(*) 
           from av_accounts_main as a,av_member as b
           where a.owner_id = @no 
     and   b.manager_id =  @center 
     and   a.store_flag='Y'
      

  3.   

    我想你是想查询的是某个字段中要含某个常量的记录,故可以这样修改语句:
    select @no = '常量值'
          select @no = '%' + @no
          select @center = '%' + @member_idselect @record_count=count(*) from av_accounts_main as a,av_member as b
         where a.owner_id like @no and b.manager_id like @center and a.store_flag='Y'
      

  4.   

    我觉得你的连接有问题,
    a,b两个表的关系是什么?
    你的查询语句显示a,b是完全没有关系的表,所以在不加条件的情况下是总记录数=a的条数*b的条数
    试试找出a,b间的关系用左联结select * from table1 a
    left join table2 b a.ID=b.ID