I’m trying to find users that opened their email that they got during 10 minutes from where a user got the email, however, for me it shows every user, not just users that opened their email that they got 10 minutes from where a user got an email.
Code that I tried to use
SELECT s.id_user as "users opened emails during 10 minutes" FROM emails_clicks as c JOIN emails_sent as s WHERE TIMESTAMPDIFF(MINUTE, s.date_sent, c.date_click) < 10 GROUP BY s.id_user
`emails_sent` - table of sent emails: a. `id` - a unique id of the sent letter b. `id_user` - the user to whom the letter was sent. (FK) -> `users`.`id` c. `id_type` - email type d. `date_sent` - date and time of sending the letter `emails_clicks` - table of clicks on emails: a. `id` - a unique id click on the letter b. `id_email` is not a unique click email id . (Foreign Key) -> `emails_sent`.`id` c. `date_click` - date and time of the click on the letter
Leave an answer