首页 新闻 会员 周边

这条sql语句能一眼看懂吗,这样写可好

0
悬赏园豆:5 [待解决问题]

SELECT article_id,title,add_time, from ecs_article as t1 where (SELECT count(*) from ecs_article as t2 where t1.cat_id = t2.cat_id and t2.add_time >t1.add_time) <3

多啦C梦的主页 多啦C梦 | 初学一级 | 园豆:86
提问于:2018-10-26 18:01

SELECT t1.article_id,t1.cat_id,t1.title,t1.link,t1.content,t1.file_url,t1.add_time from ecs_article as t1 where (SELECT count(*) from ecs_article as t2 where t1.cat_id = t2.cat_id and t2.add_time >t1.add_time) <5 and t1.cat_id in (27,28)

多啦C梦 5年前
< >
分享
所有回答(4)
0

第一条SQL有问题,from前面直接是逗号的吗?
建议放工具上自行测试,工具可以选择datagrip .

泡沫幻影 | 园豆:108 (初学一级) | 2018-10-26 20:10
0

子查询嵌套没毛病,from前面多了个逗号,执行错的

你的孤独虽败犹荣 | 园豆:258 (菜鸟二级) | 2018-10-27 11:27
0

你这个是什么业务呢,没看懂业务

寻找普拉多 | 园豆:299 (菜鸟二级) | 2018-10-27 17:48
0

查询cat_id 重复三次的数据

lanyefeng2008 | 园豆:20 (初学一级) | 2018-11-12 09:14
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册