MySQL:计算行数时出现问题
这是否应该计算表中每个 link_id 的出现次数?
SELECT link_id, count(*) FROM table group by link_id
我认为应该如此,但如果我只是执行,
SELECT * FROM table
我会得到不同的结果。例如,对于链接 7,我在第一个查询中得到的计数为 40,但使用“select *”我发现链接 7 只有 4 行...发生了什么事?
Is this supposed to count the appearances of each link_id on the table?
SELECT link_id, count(*) FROM table group by link_id
I think it should, but if I just execute
SELECT * FROM table
I get different results. For example, for link 7 I get a count of 40 in the first query, but using 'select *' i see that there are only 4 rows of link 7... What's going on?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,应该这样做,
当然,这样做会更容易,
这会给你一个包含 link_id 数量的单行
,或者
返回包含每个计数的多行
关于你提到的原始问题,每个有多个行id,你在哪里加入吗?
您确定 phpMyAdmin 或类似的程序不会限制您所看到的行数吗?
Yes it is supposed to do that,
Surely it would be easier to do a
This would give you a single row containing the amount of link_id's
Alternatively
Returns multiple rows containing the count of each
With regard to the original question you mention there are multiple rows per id, are you doing a join any where?
Are you sure phpMyAdmin or similar isn't limiting the amount of rows you are seeing?