I am working on some reports and I am trying to create a query that would select a different query depending on the date selected, this is a simplify version of what I am trying to achieve
SELECT *
FROM
IF(YEAR('###date start###'=2011),table_2011,table)
WHERE
date_start BETWEEN '###date start###' AND '###date end###'
###date start###
and ###date end###
are parameters entered by the user.
I cannot use the language to select the different table depending on the date as this is only an example and I might have other parameters passed that would select a different table.
I am thinking that I will need to create a new preg_replace and force the person that create the queries to add something like ###if(test,val2,val2)###
but if mysql can already do this I would not like to re-invent the hot-water.
Thank you
EDIT
While waiting for a better solution, I changed the "search replace" function from a simple:
###search###
=> value
(where the ###search### was showing to the end user as a field to manually enter), to also accept a new field formatted like
LLLlabel[option:value,option:value,option:value,....]LLL
Not the best solution as I wish I could do it with MySQL only as this solution is only an annoyance to the end user to have to select an extra parameter.
Please keep in mind that the question is only a VERY simplified version of the query, the query can be part of subqueries, or unions, or joins and not only have a time
separation