只能连续回复3次无奈再次发贴

legendnan 2014-02-26 12:10:00
引用 1 楼 wwwwb 的回复:
select * from tt a where 2>=(select count(*) from tt where a.title=title)
select userid,group_concat( title),group_concat(distinct oid) from `djs_shops_products` group by userid;
...全文
141 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
WWWWA 2014-02-26
  • 打赏
  • 举报
回复
SELECT * FROM `products` a WHERE 2<=(SELECT COUNT(*) FROM `products` WHERE a.title=title AND a.userid=userid);
legendnan 2014-02-26
  • 打赏
  • 举报
回复
引用 6 楼 WWWWA 的回复:
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 全程
打字比较慢。把表结构和数据大致的写了下。想要的结果也下了下!望版主指导
legendnan 2014-02-26
  • 打赏
  • 举报
回复
创建表结构: 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|
WWWWA 2014-02-26
  • 打赏
  • 举报
回复
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 全程
WWWWA 2014-02-26
  • 打赏
  • 举报
回复
贴建表及插入记录的SQL,及要求结果出来看看 精简一下表结构,只要需要的内容 select * from tt a where 2>=(select count(*) from tt where a.title=title and a.userid=userid) 应该可以 不要图片
legendnan 2014-02-26
  • 打赏
  • 举报
回复
引用 3 楼 legendnan 的回复:
[quote=引用 1 楼 JenMinZhang 的回复:] 其实你可以把 ,数据库表结构 及测试数据展示出来,再详细说明 到底需要什么样的查询结果,大家应该可以解决你的问题。(在问题上解决问题 不可取)
引用 2 楼 WWWWA 的回复:
select * from tt a where 2>=(select count(*) from tt where a.title=title) 直接运行,不加入group_concat,结果是什么 贴建表及插入记录的SQL,及要求结果出来看看
直接发我们数据库表了,字段蛮多的。 数据库表 表结构 想要的结果: 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显示出来。如果只有一个就不需要显示了 [/quote]
legendnan 2014-02-26
  • 打赏
  • 举报
回复
引用 1 楼 JenMinZhang 的回复:
其实你可以把 ,数据库表结构 及测试数据展示出来,再详细说明 到底需要什么样的查询结果,大家应该可以解决你的问题。(在问题上解决问题 不可取)


引用 2 楼 WWWWA 的回复:
select * from tt a where 2>=(select count(*) from tt where a.title=title)
直接运行,不加入group_concat,结果是什么

贴建表及插入记录的SQL,及要求结果出来看看

直接发我们数据库表了,字段蛮多的。
数据库表
表结构
想要的结果:
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显示出来。如果只有一个就不需要显示了


WWWWA 2014-02-26
  • 打赏
  • 举报
回复
select * from tt a where 2>=(select count(*) from tt where a.title=title) 直接运行,不加入group_concat,结果是什么 贴建表及插入记录的SQL,及要求结果出来看看
知道就是你 2014-02-26
  • 打赏
  • 举报
回复
其实你可以把 ,数据库表结构 及测试数据展示出来,再详细说明 到底需要什么样的查询结果,大家应该可以解决你的问题。(在问题上解决问题 不可取)

56,677

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧