Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 646515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:37:13+00:00 2026-05-13T21:37:13+00:00

I have a table where I should count if an user has reached a

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:37:13+00:00Added an answer on May 13, 2026 at 9:37 pm

    What is the column “warn_penalty”. May I assume it’s the same as “warning”? If so, simply change COUNT() to SUM(). With some additional fixing to eliminate the second table:

    SELECT user_id, SUM(warning)
    FROM table_warnings 
    WHERE  warning_date >= '2010-02-05 12:59:00'
    GROUP BY user_id
    HAVING SUM(warning) >= 3
    

    will return all users who are banned.

    Alternatively, if you have a user_id and wish to know whether it is banned or not:

    SELECT SUM(warning)
    FROM table_warnings 
    WHERE user_id = 5478 AND warning_date >= '2010-02-05 12:59:00'
    

    and check the result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.