0

I have mutliple tables with same name with added date in the last as abc_2016_09.

Now How can i call this mentioned statement, pls help.

SET @var = concat('ABC_table','_',date_format(curdate(), '%Y'),'_',date_format(curdate(), '%m'));

AND THEN

select * from @var

error code 1069 is coming.

Ullas
  • 11,450
  • 4
  • 33
  • 50
Vishan Rana
  • 307
  • 2
  • 4
  • 9

1 Answers1

0
SET @var = concat('abc_table','_',date_format(curdate(), '%Y_%m'));

SET @statment = concat('select * from ', @var);

PREPARE stmt FROM @statment; 
EXECUTE stmt;

Check it in mysql workbench, It does not return row in mariadb.

khalid
  • 175
  • 5
  • 15