Hi, I have a table
where I should count if an user has reached a number of penalities like 3, so if the user reach or surpass 3 points, he's banned:
table_warnings
- id
- user_id
- warning
- warning_date
id user_id warning warning_date
1 5478 1 2010-02-25 12:59:00
2 5478 1 2010-02-28 08:27:00
3 5478 2 2010-03-01 22:44:11
I've started this question, where the user KM helped me to fine a solution of a SELECT
like this one:
SELECT COUNT(warning)
FROM table_warnings AS w
INNER JOIN table_users AS u
ON w.user_id = u.user_id
WHERE w.user_id = 5478 AND warning_date >= '2010-02-05 12:59:00'
HAVING COUNT(warning) >= 3
Can I find a way for a SELECT
to retrieve how many penality points the user has got in the last 30 days?