After I read about prepared statement,I can set prepared statement like following. It worked, but I haven't understood what is the merit of prepared statment. because I wonder what is the merit beyond normal sql in prepared statment ?
SELECT CONCAT("SELECT *
"FROM table",
"Where snapshot_day >= cast(now() as date) - interval 9 day ",
"And type in ('Daily') ",
"GROUP BY 1") INTO @myquery;
SELECT @myquery;
PREPARE stmt FROM @myquery;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
If someone has opinion, please let me know