后台调用多个表 表a  表 b  表 c  表 d在前台的一个表格里面显示 a表  一共多少条    认证多少条
 b表  一共多少条    认证多少条
 c表  一共多少条    认证多少条
 d表  一共多少条    认证多少条
求思路和例子,在线关注,及时结帐。

解决方案 »

  1.   

    这几个表有关联么?
    有的话用inner join如果表结构都一样就用 union 连接
      

  2.   

    我SQL 不太好,你能帮我写一下这个语句不~~~
      

  3.   

    他们之间有关联 关联都是user_name
      

  4.   

    这样写也行。
    select aa.xxx,bb.xxx,cc.xxx,dd.xxx from a aa,b bb,c cc,d dd where aa.user_name=bb.user_name and aa.user_name=cc.user_name and aa.user_name=dd.user_name and 加上你的查询条件。不知道你的user_name是怎么对应的,where条件还可以这样
    where aa.user_name=bb.user_name and bb.user_name=cc.user_name and cc.user_name=dd.user_name and .............
      

  5.   

    大哥们 我这个查询的时候 需要 count() 好几次。。怎么办。。
      

  6.   

    select count(*) from a aa,b bb,c cc,d dd where aa.user_name=bb.user_name and aa.user_name=cc.user_name and aa.user_name=dd.user_name and ......或些个存储过程调用
      

  7.   

    说明
    ————————————————————————————————————
     从session 里面区一个值 让a,b,c,d表里面的值得都等于这个然后count()a,b,c,d表里面的信息,   在count(renzheng)a,b,c,d表里面的信息也就是count()两次
      

  8.   

    就是把这几个语句综合起来select count(*) from a where user_name = 'xuemiao'select count(*) from a where supply_authentication = 'y' and user_name = 'xuemiao'
    select count(*) from b where user_name = 'xuemiao'select count(*) from b where supply_authentication = 'y' and user_name = 'xuemiao'
    select count(*) from c where user_name = 'xuemiao'select count(*) from c where supply_authentication = 'y' and user_name = 'xuemiao'
    select count(*) from d where user_name = 'xuemiao'select count(*) from d where supply_authentication = 'y' and user_name = 'xuemiao'
      

  9.   

    不会写存储过程就重复执行调用吧。
    sql1语句
    "select count(*) from a aa,b bb,c cc,d dd where aa.user_name=bb.user_name and aa.user_name=cc.user_name and aa.user_name=dd.user_name and aa.aa_session = " + session + " and bb.bb_session = " + session + " and cc.cc_session = " + session + " and dd.dd_session = " + session;sql2语句
    "select count(renzheng) from a aa,b bb,c cc,d dd where aa.user_name=bb.user_name and aa.user_name=cc.user_name and aa.user_name=dd.user_name and aa.aa_session = " + session + " and bb.bb_session = " + session + " and cc.cc_session = " + session + " and dd.dd_session = " + session;
      

  10.   

    同意 Yzw_2006() 
    用union
      

  11.   

    select *
    into #tempT
    from a as aa (nolock)
    join b as bb (nolock)
    on aa.username = bb.username
    join c as cc (nolock)
    on bb.username = cc.username
    join d as dd (nolock)
    on cc.username = dd.username
    where dd.username = @username
    //**then you can calculate the value you want***
    select count(1) from #tempTi don't know the condition you count for, so please add it yourself,i think this quality will be better if you user temp table.