Вот что еще накопал:
CREATE TRIGGER `update_test` AFTER INSERT ON `_test`
FOR EACH ROW BEGIN
SET @iid = (SELECT value FROM _test ORDER BY id DESC LIMIT 1);
SET @filepath = CONCAT(@iid, '.csv');
SELECT *
FROM _test
ORDER BY id
DESC LIMIT 1
INTO OUTFILE @filepath
CHARACTER SET cp1251 FIELDS TERMINATED BY ';' ENCLOSED BY '' LINES TERMINATED BY '\n';
END;
Создание переменной @filepath. Но я что-то упускаю:
[42000][1064] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@filepath CHARACTER SET cp1251 FIELDS TERMINATED BY ';' ENCLOSED BY '' at line 9