选择count(*)多行并显示结果
我必须执行一个包含 SELECT COUNT 的 UPDATE 表,但这花费的时间太长。 这是我原来的查询,
UPDATE list SET count =
(SELECT COUNT(*) FROM set_1 WHERE set_1.start BETWEEN list.start AND list.end);
我只有 100 行需要更新,所以我想只做一个选择计数并将其显示在屏幕上。然后我会将结果复制/粘贴到我的 Excel 电子表格上。
我本来打算这样做,但它只返回一个数字(而不是 100 行数字),
SELECT COUNT(*) FROM set_1,list WHERE set_1.start BETWEEN list.start AND list.end;
但这不起作用,它返回所有 SELECT COUNT 中的一大数字。
任何人都可以帮我解决这个问题吗?
I have to do an UPDATE table that includes a SELECT COUNT but that takes way too long.
That was my original query
UPDATE list SET count =
(SELECT COUNT(*) FROM set_1 WHERE set_1.start BETWEEN list.start AND list.end);
I just have 100 rows to update so I was thinking of just do a select count and display it on screen. And then I'll copy/paste the result on my excel spreadsheet.
I was intended to do this, but it returns only one number (and not 100 rows of number)
SELECT COUNT(*) FROM set_1,list WHERE set_1.start BETWEEN list.start AND list.end;
But that doesn't work it returns one big number of all the SELECT COUNT together ..
Anyone can help me out with this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在 set1 和 list 之间进行笛卡尔积
You are doing a cartesian product between set1 and list