如有一个表(a)字段为 mobile(手机号)(,wap_type(站点类型),wap_name(站点名称)
另外一个表(b)字段分别为 mobile(手机号),group(记录),再一个表(c)的字段为mobile(手机号),record(记录)。
现在要建立一个视图实现这样的功能:就是视图有三个字段。
mobile(手机号),在b表中与该手机号相对应的的总的记录,在c表中与该手机号相对应的总的记录

解决方案 »

  1.   

    select a.mobile,b.group,c.record from a,b ,c where a.mobile=b.mobile and a.mobile=c.mobile
      

  2.   

    对了,总的记录是什么意思,是不是记录个数?若是用以下语句
    select a.mobile,sum(b.group),sum(c.record) from a,b ,c where a.mobile=b.mobile and a.mobile=c.mobile group by a.mobile
      

  3.   

    select mobile,(select count(1) from b where a.mobile=b.mobile),
                  (select count(1) from c where a.mobile=c.mobile)
      from a;