22 Dec 2016

Using a Generated Column to help with date lookups

I have a table that has two columns: year and month.
While its ok to search on exact dates or by year, it is harder to search between two dates.

Lets see if we can solve this issue by using a generated column.
(Table taken from https://github.com/jonathanvx/uk_land_registry_paid_dataset)


3 comments:

  1. If you used a proper date column like your supposed to you wouldnt have this problem.

    ReplyDelete
  2. Indeed, but its nice to know that a bad table design can be fixed with a generated column or if an additional requirement was added later on.

    ReplyDelete
  3. Ah! also, the original requirement was for a CSV file to fit for an Excel/Pivot Table analysis. Not a MySQL table.

    ReplyDelete