Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
The structure of your tables is a little confusing, it's good if this is just an example or some part of the logic is not voiced. But in general, it’s strange to store a person’s mail in the table rows all the time, wouldn’t it be more correct to make a userId column and indicate the user id in it in the users table where there is all the information about him? In general, okay.
In your case it could be something like:
SELECT COUNT(`id`) as history_user_count, `email`, MAX(`date`), (SELECT COUNT(id) FROM lesson WHERE id_course = '3' OR id_course = '4') as lessons FROM `history` WHERE 1 GROUP BY `email` HAVING lessons =< history_user_count
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question