I have a table where some values are null.
mysql> select * from temp ;
+-----------+----------+----------+----------+-------+
| firstname | lastname | address1 | address2 | state |
+-----------+----------+----------+----------+-------+
| john | wall | NULL | NULL | CA |
+-----------+----------+----------+----------+-------+
1 row in set (0.00 sec)
When I select from this table from commandline with --batch table and write it to file I get something like this
mysql -u**** -p**** --batch temp_work -e "select * from temp" > temp.tab
cat temp.tab
firstname lastname address1 address2 state
john wall NULL NULL CA
Is there a way to force mysql to print those NULL as \N instead so that it will be handled in proper way when I try to load the data back.
I do know the option of SELECT INTO OUTFILE where null will be written as \N, but I want to find a work around for this problem for various reasons.
Any help is greatly appreciated.
Thanks
I think you can use ISNULL(myColumn, "with whatever value you want to replace null with "). Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With