Mysql query: How do I select ALL THE VOTES from ALL USERS FROM TODAY only when premium = 'yes'?
I have tables:
users
with the 开发者_JAVA百科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'?
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())
精彩评论