MySQL - Selecting data from multiple tables all with same structure but different data

前端 未结 6 1652
南笙
南笙 2020-11-28 03:46

Ok, here is my dilemma I have a database set up with about 5 tables all with the exact same data structure. The data is separated in this manner for localization purposes an

6条回答
  •  没有蜡笔的小新
    2020-11-28 04:14

    Your original attempt to span both tables creates an implicit JOIN. This is frowned upon by most experienced SQL programmers because it separates the tables to be combined with the condition of how.

    The UNION is a good solution for the tables as they are, but there should be no reason they can't be put into the one table with decent indexing. I've seen adding the correct index to a large table increase query speed by three orders of magnitude.

提交回复
热议问题