I am at my wits end and could really do with some expert advise. Let me try to describe my issue.
I am trying to generate a PHP table that displays period data. Each year has 13 periods, each period having 4 weeks.
Hence we have a period table with fields
and a period data table with fields
periodnumber (references previous table)
weeknumber (a number from 1 to 4)
Period refererences another table which has the perdio name, financial year etc.
However I want to generate a query that will generate a table with the current period (weeks 1 to however many there are) and the last period (4 weeks)
I have been able to generate a routine that can easily pull off the latest period data with the following
WHERE period1.periodnumber =
ORDER BY ID DESC
this simply takes the latest period from the period table, and uses that as a reference to pull off the latest period data. However, I have no clue how to pull of the period before, and also clearly distinguish these results for easy display later on a PHP generated table. I have tried the IN statement just before the nested query, but am told my version of MYSQL does not allow it.
Any pointers would be appreciated. The query above is the closest I have come, I have had many complicated abortive attempts not worth posting.