select * from tt a where 2>=(select count(*) from tt where a.title=title)
直接运行,不加入group_concat,结果是什么贴建表及插入记录的SQL,及要求结果出来看看

解决方案 »

  1.   


    直接发我们数据库表了,字段蛮多的。
    数据库表
    表结构
    想要的结果:
    userid     group_concat(title)   group_concat(oid)         group_concat(statue)
    1          保过,保过,教程      sp111,sp234,sp134       1  0  1
    根据这个statue属性去除title值相同的内容为1 就保留 为0 就去除。
    userid     group_concat(title)   group_concat(oid)         group_concat(statue)
    1          保过,保过            sp111,sp234              1  0       结果这里可能表达不清,技术实在是有限。
    就是想把重复的信息显示出来!比如userid=1 时有2个以上的保过班,那么就把这些保过班的oid和statue显示出来。如果只有一个就不需要显示了     
      

  2.   


    直接发我们数据库表了,字段蛮多的。
    数据库表
    表结构
    想要的结果:
    userid     group_concat(title)   group_concat(oid)         group_concat(statue)
    1          保过,保过,教程      sp111,sp234,sp134       1  0  1
    结果:
    userid     group_concat(title)   group_concat(oid)         group_concat(statue)
    1          保过,保过            sp111,sp234              1  0       结果这里可能表达不清,技术实在是有限。
    就是想把重复的信息显示出来!比如userid=1 时有2个以上的保过班,那么就把这些保过班的oid和statue显示出来。如果只有一个就不需要显示了     

      

  3.   

    贴建表及插入记录的SQL,及要求结果出来看看
    精简一下表结构,只要需要的内容
    select * from tt a where 2>=(select count(*) from tt where a.title=title
    and a.userid=userid)
    应该可以不要图片
      

  4.   


    oid userid title
    4 1 vip
    6 2 vip
    8 3 全程
    2 4 保过
    5 4 基础
    11 4 全程
    10 4 全程
    1 4 全程
    7 4 通关
    9 5 全程
    select * from tty a where 2<(select count(*) from tty where a.title=title
     and a.userid=userid)oid userid title
    1 4 全程
    10 4 全程
    11 4 全程
      

  5.   

    创建表结构:
    create table `products`(`userid` int(20) not null,
    `status` int(5) not null,
    `title` varchar(20) not null,
    `oid`  varchar(20) not null
    )
    插入数据:insert into `products`(`userid`,`status`,`title`,`oid`) values('1','1','保过版','sp1'),('1','0','保过版','sp2'),('1','0','保过版','sp3'),('1','1','vip班','sp6'),('2','1','vip班','sp4'),('2','0','vip班','sp5'),('2','1','保过版','sp7')想要的结果:
    +------+-------+--------+--------+
    userid | status | title   |  oid
    +------+-------+--------+--------+
    |1    |1    |保过版|sp1|
    |1    |0    |保过版|sp2|
    |1    |0    |保过版|sp3|  
    |2    |1    |vip班|sp4|
    |2    |0    |vip班|sp5|
      

  6.   

    SELECT * FROM `products` a WHERE 2<=(SELECT COUNT(*) FROM `products` WHERE a.title=title
      AND a.userid=userid);