can I use a variable to specify OUTFILE in mysql

前端 未结 4 639
南方客
南方客 2020-12-09 09:47

Is there a way to do something like the following ? which doesn\'t work but shows what I want to do

SET @OutputPath = \'/Users/jo/Documents\'
SET @fullOutput         


        
4条回答
  •  旧巷少年郎
    2020-12-09 10:42

    I have a low carma so I'm posting an answer that should go as a comment to Sami's post - you need to enclose the file name by quotes (note added ' before and after @fullOutputPath):

    set @q1 := concat("SELECT * INTO OUTFILE '",@fullOutputPath,
    "' FIELDS TERMINATED BY ',' 
    OPTIONALLY ENCLOSED BY '\"'
    FROM database.tableName");
    

提交回复
热议问题