I have the following query:
SELECT
id AS CODIGO,
nome AS NOME,
versao AS VERSAO,
build AS BUILD,
data AS DATA
FROM sistema
INTO OUTFILE 'D:/servicos/export/exportaVersao.csv'
FIELDS TERMINATED BY ';' ENCLOSED BY '"' LINES TERMINATED BY '\n';
I would like to change the export version to some random number, eg:
'D:/servicos/export/256589.csv'
I got this query that generates this number:
(SELECT FLOOR(10000 + (RAND() * 99999)))
How can I concatenate with each other?
If it is not possible, instead of this random number it could be: 170704 (data = aa/mm/dd)
Attempt to concatenate:
SELECT
id AS CODIGO,
nome AS NOME,
versao AS VERSAO,
build AS BUILD,
data AS DATA
FROM sistema
INTO OUTFILE concat(concat('D:/servicos/export/','' ,(SELECT FLOOR(10000 + (RAND() * 99999)))),'.','csv')
FIELDS TERMINATED BY ';' ENCLOSED BY '"' LINES TERMINATED BY '\n';
Error:
0 55 01:02:58 SELECT - QUERY id AS CODE, name AS NAME, VERSION VERSION, build AS BUILD, date AS DATA FROM system INTO OUTFILE concat ('D: / services / export /', '', (SELECT FLOOR (10000 + (RAND () * 99999)))), '.', 'Csv') FIELDS TERMINATED BY ';' ENCLOSED BY '"' LINES TERMINATED BY '\ n' Error Code: 1064. You have an error in your SQL syntax; the manual that corresponds to your MariaDB server version for the right syntax to use near concat (concat ('D: / services / export /', '' , (SELECT FLOOR (10000 + (RAND () * 99999))) 'at line 8 0.000 sec