troubleshooting Question

Select Into Outfile Variable Name

Avatar of dodge20
dodge20 asked on
MySQL Server
8 Comments1 Solution1152 ViewsLast Modified:
Is it possible to do a select into outfile and have the output file be a variable name? I am trying to write a cursor that will loop through a recordset, pass a variable to a procedure that exports a text file for each variable passed. Before I get to deep into this I would like to know if it is possible.

Here is my query.

select distinct student_name,student_address,student_hometown,student_state,student_honors,md_ID
from student,ht_zips,media
where student_zip = htz_zip
and htz_media_id = md_ID
into outfile 'C:/tmp/myvar.txt'
Fields Terminated by ','
Lines Terminated by '\r\n'

Also is it possible to skip fields in the output file? So if student_honors is null that it would skip that field?
I tried the IFNull, but that still prints a comma. I would like this to be skipped completely.

ASKER CERTIFIED SOLUTION
Kim Ryan
IT Consultant

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 8 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 8 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004