Skip to content
Advertisement

Compare two MYSQL tables and return missing dates and group by column

I have two tables. I want to compare table A with B and get the missing date from with name of the user.

TABLE A

TABLE B

EXPECTED OUTPUT

Also, Along with it can I get the count of the missing dates for each user if possible?

Advertisement

Answer

You must cross join Table B to the distinct names of Table A and then left join Table A to filter out the matching rows:

If you want to count the missing_dates use the same query and group by name:

See the demo.
Results:

and:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement