I have few tables
table201202
table201203
table201204
table201205
...
tableversion
In tableversion I have columns:
Version_ID Admin_ID MONTH YEAR
I need to get something like this
Select *
FROM tableversion
LEFT JOIN table(tableversion.month tableversion.year) on
table(tableversion.month tableversion.year).Version_ID=tableversion.version_id
But in tableversion I've got months without leading 0 so i must check if there is 5 and then change it to 05, if variable is 12 then nothing. How can I do it?
Ok, so now i have something like this
SELECT *, CONCAT('table',IF(tableversion.month < 10, CONCAT('0', tableversion.month ), tableversion.month ),year) as year
FROM tableversion
LEFT JOIN year ON tableversion.version_id=year.version_id WHERE ADMIN_ID=11
#1146 - Table 'database.year' doesn't exist
But it does not work