• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 392
  • Last Modified:

How to change blank to null when export into outfile?

select * into Outfile 'C:/Java/migrate_boaeft1.txt' fields terminated by "'" lines terminated by '#' from boaeft;

Above is my statement to output to an outfile, it works file, however if my table has an empty entry then I would get '' ( 2 single quotes)   is there a way I can export so when there is a blank, this will change the value to null or 0 so instead of having '', i would have 'null' or '0' ?
1 Solution
You would have to specifically list all the fields you are dumping in your select statement.  If field4 is the field you want this behavior for:

select field1, field2, field3, if(length(field4) = 0, 'null', field4), field5, field6..... into Outfile...
fylix0000Author Commented:
Thank you NovaDenizen  :),, quite simple yet I do not know how to come up with it.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now