Today there is a requirement that MySQL multiple tables merge a table to find out how many userid (de-weight) the table has.
First of all, my idea is to combine multiple tables with union into a single table, then groupby, and finally sum (userid)to get the number.
Select COUNT(DISTINCT(`user_id`))
from (Select user_id fromlog_20160706Union Select user_id fromlog_20160707UnionSELECT user_id fromlog_20160708UNIONSELECT user_id fromlog_20160709UNIONSELECT user_id fromlog_20160710UNIONSELECT user_id fromlog_20160711UNIONSELECT user_id fromlog_20160712Order by user_id
) asTB//Here as must be extended to the entire section of select outside
It can be used, but it takes a long time if the table has a large amount of data.
Then think of another way of thinking, I can script from each table read out, count the players of each table, and then go to the weight (unique).
MySQL Multiple tables merge a table to find