简体   繁体   English

Mysql查询:仅当premium ='yes'时,如何才能从“今天所有用户”中选择“所有投票”?

[英]Mysql query: How do I select ALL THE VOTES from ALL USERS FROM TODAY only when premium = 'yes'?

I have tables: 我有桌子:

 users
    with the fields id, premium
 votes
    with the fields userid, date.

How do I select ALL THE VOTES from ALL USERS FROM TODAY only when premium = 'yes'? 仅当premium ='是'时,如何才能从今天的所有用户中选择所有投票?

Use: 采用:

SELECT COUNT(*)
  FROM VOTES v 
  JOIN USERS u ON u.id = v.userid
              AND u.premium = 'yes'
 WHERE v.date = CURRENT_DATE()
select * from votes v, users u 
where v.userid = u.id and u.premium = 'yes' 
      and v.date = today()
select count(a.id) from users a, votes b where a.id=b.userid and a.premium='yes' and b.date=CURDATE() 
SELECT votes.* FROM users, votes WHERE users.Id = votes.userid WHERE premium='yes' AND date=DATE(NOW())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从数据库中获得最多票的 select 用户? - How to select users with most votes, from a database? mysql从今天开始到现在全部选择 - mysql select all from today up until now select 如何仅从具有所有刷卡记录的表中刷卡用户 - How do select only swipe-in users from the table which has all swipe records 数据库查询计数所有是/否投票及其所属的db记录? - database query count all yes/no votes and the db record they belong to? 优化查询:从用户的项目中获得所有投票 - optimize query: get all votes from user's item 如果所有线索均处于活动状态且引线均为0且primary_email =第二表中的是,则MySQL INNER JOIN仅从第一表中选择一行 - MySQL INNER JOIN select only one row from first table if all leads active = 0 and primary_email = Yes in second table MYSQL:如何仅选择今天注册的用户 - MYSQL: How to select only users who signed up today 如何允许所有SQL用户从视图中读取 - How do I allow all SQL users to read from a view 如何选择最近2个小时内或完全没有使用Mysql更新分数的用户 - How do I select users that have not had their score updated within the last 2 hours or at all using Mysql MYSQL 如何从表中选择所有电子邮件但限制具有相同域的电子邮件数量 - MYSQL How do I Select all emails from a table but limit number of emails with the same domain
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM