• 筛选功能的实现


    用户表---   user  
       
      uid       username  
      1           user1  
      2           user2  
      3           user3  
      .........  
       
      数据表1---     table1  
       
      id     useranme     a     b     c     d  
      1         user1         1     1     1     1  
      2         user1         1     1     1     1  
      3         user2         1     1     1     1  
      4         user3         1     1     1     1  
      5         user2         1     1     1     1  
      6         user3         1     1     1     1  
       
      数据表2   ----table2  
      id     username     suma     sumb     sumc     sumd  

      select   username,suma=sum(a),sumb=sum(b),subc=sum(c),subd=sum(d)   from   table1   aa  
      where   exists(   select   *   from   user1   where   username=aa.username)  
      group   by   username 

       
      select   u.username,suma=sum(a),sumb=sum(b),subc=sum(c),subd=sum(d)  
      from ((select   *   from   user1) as u inner join  table1 on  u.username=table1.username)
       group   by   u.username  

  • 相关阅读:
    Python 模块管理
    Python 练习: 计算器
    Linux 系统性能分析工具 sar
    Python 正则介绍
    Python ConfigParser 模块
    Python logging 模块
    Python hashlib 模块
    Python sys 模块
    09 下拉框 数据验证
    08 条件排序
  • 原文地址:https://www.cnblogs.com/ZhengGuoQing/p/1050577.html
Copyright © 2020-2023  润新知