In MySQL it is not possible to specify the outfile as an expression/variable. The only way I was able to do this was to prepare the statement (and in my case, as part of a stored procedure):
SET @query = CONCAT("SELECT t1.field1 FROM table1 t1 LIMIT 1 INTO OUTFILE /my_path/", myvar, ".txt" );
PREPARE statement FROM @query;
EXECUTE statement;
I don't think you can reference a column/field from your source table in this manner however.
You would have to do an initial SELECT statement to get the value of t1.field1 (perhaps using SELECT ... INTO syntax), and then use this variable with the syntax above