How to query the horizontal table?

to query the data after horizontal split, suppose the data of a business is split horizontally, and the monthly records are stored in a table. The data of each table is about 1000w. There are already more than 20 tables, such as table_201606,.,table_201702.table_201804 . If you need to query the data from July 2016 to March 2018, how to query it? Performance and query speed need to be considered.


there is no special way to do this, do a query for each single table, and then summarize the result set.

can be a dynamically generated statement with union, or you can cycle through the application to query a single table and then merge the result sets.


isn't the year behind your table? Use PHP to first assemble the table to be queried, and then summarize the data. Another way is to query the main table according to the rules of your horizontal table. Just choose one of the two methods

Menu