Jump to content

not show null values in results


cougar23

Recommended Posts

Example

[pre]

mysql> SELECT * FROM testtable;

+-------------+--------+-----------+-----------+

| idtesttable | school | readscore | mathscore |

+-------------+--------+-----------+-----------+

|          1 | A      |        60 |        50 |

|          2 | A      |        40 |      NULL |

|          3 | A      |      NULL |        70 |

|          4 | B      |        40 |      NULL |

|          5 | B      |      NULL |        50 |

+-------------+--------+-----------+-----------+[/pre]

 

But you can change the NULLs by

[pre]

mysql> SELECT school,

    -> IFNULL(readscore,'') AS readscore,

    -> IFNULL(mathscore,'') as mathscore

    -> FROM testtable;

+--------+-----------+-----------+

| school | readscore | mathscore |

+--------+-----------+-----------+

| A      | 60        | 50        |

| A      | 40        |          |

| A      |          | 70        |

| B      | 40        |          |

| B      |          | 50        |

+--------+-----------+-----------+

Perhaps I didn't word my question well.  I'm not referring to how to make a query that ignores NULLs, but a configuration setting that when MySQL outputs the results of a query it outputs a blank space instead of NULL where a value is null.  I'll provide an example.  I've seen someone who had their MySQL set up this way, same version I'm using, but that person no longer works with me.

 

Currently

+-------------+--------+-----------+------------+

| idtesttable  | school  | readscore  | mathscore  |

+-------------+--------+-----------+------------+

|          1      | A        |        60    |        50    |

|          2      | A        |        40    |      NULL    |

|          3      | A        |      NULL    |        70    |

|          4      | B        |        40    |      NULL    |

|          5      | B        |      NULL    |        50    |

+-------------+--------+-----------+-----------+

 

Desired

Currently

+-------------+--------+-----------+------------+

| idtesttable  | school  | readscore  | mathscore  |

+-------------+--------+-----------+------------+

|          1      | A        |        60    |        50    |

|          2      | A        |        40    |                |

|          3      | A        |                |        70    |

|          4      | B        |        40    |                |

|          5      | B        |                |        50    |

+-------------+--------+-----------+-----------+

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.