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
In my opinion this is caused from what appears to be poor table design (I am guessing that is just an example to simply your problem, but bear with me, and I think this concept could be modeled better.
Here are the tables:
Things Things_Months Months
thing_id thing_id Month_id
thing_info month_id Month_Name
thing_month_id order_field
and here would be the sql:
select thing_info, month_name
from things, things_months, months
where things.thing_id = things_months.thing_id
and things_months.month_id = months.month_id
order by things.things_info, months.order_field
The results would be
thingy 1, January
thingy 1, February
thingy 2, April
thingy 3, November
thingy 3, December