Format file name in MySql

47
Views
1
Answers

Hi,
I am trying to format the file name for outfile using variables from the table.
I've tried the following but I am getting error:

SELECT * FROM table t1 INTO 
OUTFILE  
'/my_path/', t1.field1, '.txt' ;

Can anyone suggest me?

edit | flag
William Patrick
Asked on: Jul 25, 2011 at 8:13PM

1 Answers

50
4
50

This is not possible in MySql.. but you have an alternative to this.. try using Concat function.. like..

SET @sql = CONCAT("SELECT * FROM table t1 INTO OUTFILE /my_path/", myvar, ".txt" );
PREPARE stmt FROM
@sql;
EXECUTE stmt
;

You should store the row/ field value in myvar and pass it using CONCAT function.

edit | flag
Gokul A
Answered on: Jul 25, 2011 at 8:16PM

Post your Answer

Search

Welcome to Ask Amoeba!
This is 100% free and interactive site for sharing professional Questions and Answers, Opensource projects, Interview questions.
Learners, beginners, Experts stop and share your knowledge and ideas!

Browse Categories

Browse Tags