In the database I am working on, there are 14 news tables (table1, table2 .... table14) of different cities with exact same structure. Some of the columns are: id, author, date, news_title, news_body
There are different authors who post in relevant city table. Now I want to know how many news has been posted by each author today in all 14 tables.
Here is the format of output:
author | num_of_post
bob 5
peter 12
Remember, there are 14 tables (this is the problem)
union all, but at least you've learned something about bad database design.Union, orfull joins). and drive your query against the View. But why is this data spread across 14 tables instead of being in just one with a column namedcity? Not that that is intrinsically wrong, but there are only a few good reasons to do that.