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.

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros