Mysql“不在”选择问题
我只需要在一张表中找到今天参加比赛的所有人员,而不是前几天的获胜者...
我的查询是:
SELECT Email,FName,Name,ID
FROM `voucher_registrations`
WHERE DATE_FORMAT(`Date_Submitted`,'%Y-%c-%d') = curdate()
and Email not in (select email
from `voucher_registrations`
where winner=1)
出现问题...当我尝试执行查询时,mysql 没有响应( 表中大约有 7000 行)
有什么想法吗?或者用另一种方式进行这种查询?
尼古拉斯
I need to find in one table only , all persons having played to a contest today and not be winners from previous days...
My query is :
SELECT Email,FName,Name,ID
FROM `voucher_registrations`
WHERE DATE_FORMAT(`Date_Submitted`,'%Y-%c-%d') = curdate()
and Email not in (select email
from `voucher_registrations`
where winner=1)
There is something wrong...mysql is not responding when I try to execute my query (about 7000 rows in the table)
Any idea ? Or another way to make this kind of query ?
Nicolas
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以在电子邮件字段上添加索引以加快查询速度,并在子查询中选择“DISTINCT”电子邮件以减少搜索值:
You can add an index on the email field to speed up the query and select "DISTINCT" email in subquery to reduce searched values:
尝试一下(与你的略有不同):
Try with this (slightly different from yours):
这不是等价的吗:
Wouldn't this be the equivalent: