I have two talbles a login table and a login attempts table for track worng login attempts
login table
| id | username | password |
| 1 | Jon | 1234 |
| 2 | Danny | ttttt |
| 7 | Martin | fffff |
attempts table
| id_attempts| time |
| 1 | 535353 |
| 2 | 554335 |
| 1 | 654545 |
| 1 | 566777 |
Query must identify a user as authorized, check the database for his combination of username/password but must return also the number of incorrect attempts for that user, even if the username and password are wrong. I'have try this:
SELECT u.id,count(p.id_attempts)
FROM login as l, attempts as a
LEFT JOIN
ON l.id=a.id_attempts
WHERE username=Jon
AND pass=1234
EDITED:
Exmple Jon try to login, if username and password are correct query must return jon id and 3 (number of jon wrong attempt) if jon username and password are wrong query must return only 3 (number of jon wrong attempt)
timecolumn representing ? - user3522371