MySQL count a number of entries within time period sharing at least 1 of 3 columns <p>I have a table that logs invalid user login attempts. Every time an invalid attempt is made, the username, user IP, user email and time/date is stored in the database.</p> <p>What I'd like to do is check if within ANY 24 hour time period there has been more than X invalid attempts by the same user. However, the users can change the email, username or IP at any point. So, I need to check that anyone of these 3 fields is in common.</p> <p>For example:</p> <ul> <li>User ID: 1; IP: 1.1.1.1; Email: test@test.com </li> <li>User ID: 2; IP: 1.1.1.1; Email: test2@test.com </li> <li>User ID: 1; IP: 1.1.1.2; Email: test3@test.com</li> <li>User ID: 4; IP: 1.1.1.4; Email: test@test.com</li> <li>User ID: 5; IP: 1.1.1.4; Email: test5@test.com</li> </ul> <p>All of these would match as the SAME user because they share EITHER the user ID, the IP or the email. Then I need to output all user IDs, IPs and emails so I can ban any user in another table that matches these criteria. </p>