Exporting a table from MySQL where fields that have no value will have the keyword NULL within.
| id | name | nickname | origin | date |
| 1 | Joe | Mini-J | BRAZIL | NULL |
I have written a script to automatically remove all occurrences of NULL using a one-liner sed, which will remove the NULL in date column correctly:
sed -i 's/NULL//g'
However, how do we handle IF we have the following?
| id | name | nickname | origin | date |
| 1 | Joe | Mini-J | BRAZIL | NULL |
| 2 | Dees | DJ Null Bee| US| 2017-04-01 |
| 3 | NULL AND VOID | NULLZIET | NULL| 2016-05-13 |
| 4 | Pablo | ALA PUHU MINULLE | GERMANY| 2017-02-14 |
Apparently, the global search and replace all occurrences of NULL will be removed, where even "ALA PUHU MINULLE" will become "ALA PUHU MIE", which is incorrect.
I suppose the use of regex perhaps can be useful to apply the rule? But if so, will "DJ Null Bee" be affected or will it become "DJ Bee"? The desired outcome should really be:
| id | name | nickname | origin | date |
| 1 | Joe | Mini-J | BRAZIL | |
| 2 | Dees | DJ Null Bee| US| 2017-04-01 |
| 3 | NULL AND VOID | DJ Null Bee| | 2016-05-13 |
| 4 | Pablo | ALA PUHU MINULLE | GERMANY| 2017-02-14 |
Given that NULL is a special keyword for any databases, but there is no stopping anyone from calling themselves a DJ NULL, or have the word NULL because it means differently in another language.
Any ideas on how to resolve this? Any suggestions welcomed. Thank you!