FrancisChung Posted January 27, 2018 Share Posted January 27, 2018 @bernhard, I'm a bit confused with the following SQL (SELECT month_$i FROM demo WHERE year = $year) Is there a missing "AND month = $i" in the WHERE clause or do you actually have 12 fields called (month_1 .... month_12). Asking because it's not your usual normalised database table structure. Was there a reason for going the denormalised route rather than say having a field called Month with values 1 to 12? So your query would look like : (SELECT month FROM demo WHERE year = $year and month=$i) AS month_$i Normally you might denormalise if you have too much data or reducing the number of joins in your query dramatically improves performance. Link to comment Share on other sites More sharing options...
Recommended Posts