Reputation: 23
need to add date in the file name into outfile caluse below pease suggest
SET @outpath = "/var/lib/mysql-files/";
SET @outfile = (SELECT NOW());
SET @outextension = "_StepCount.csv";
SET @SQL := CONCAT("Select Concat(ifnull(First_Name,'')," ",ifnull(Middle_Name,'')," ",ifnull(Last_name,'')) AS Name, u.email from users",@outpath,@outfile,@outextension ) ;
PREPARE stmt FROM @SQL;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
Upvotes: 1
Views: 48
Reputation: 17665
I prefer to use char(39) (single quote)
SET @SQL := CONCAT("Select Concat(ifnull(First_Name,'')," ",ifnull(Middle_Name,'')," ",ifnull(Last_name,'')) AS Name, u.email from users",
CHAR(39),@outpath,@outfile,@outextension,CHAR(39) ) ;
NB- I haven't corrected the other errors in this code but if you select @sql they should be obvious.
Upvotes: 1