I\'m working with a table in MySQL that contains the following columns:
id, january, february, march, april, etc
The data in the table looks li
What you need is an un-pivot operation. Microsoft SQL Server supports PIVOT
and UNPIVOT
as extensions to standard SQL. I don't know of any other brand of RDBMS that supports built-in pivot/unpivot functionality. Certainly MySQL does not support this.
You can't use FULLTEXT
search in this case, because as the docs say:
Full-text indexes can be used only with MyISAM tables, and can be created only for CHAR, VARCHAR, or TEXT columns.
And it wouldn't relieve you from needing to specify the columns anyway, because the MATCH()
predicate needs you to list all columns in the fulltext index.
If you can't restructure the table to store a row-per-month or a single column to encode all 12 months, then you do need to generate dynamic SQL.