Are 0 and "" empty values?

Question

In the context of this exercise, are 0 and "" empty values?

Answer

No, although logically, we may think that 0 represents some empty number or count, or that "" represents an empty text, which is not wrong, this does not mean they are empty values. In SQL tables, they are still considered to be values.

Instead, empty values in SQL would be represented with NULL, which means the absence of any value.

2 Likes

Yet when we print the select tables WHERE health IS NULL, the values in the health field are all zeroes. None of them say ‘NULL’. Why?

1 Like

I believe what is shown in the health field is not the number zero, 0, but the symbol for NULL, Ø. I don’t know why the symbol Ø is used when the table is displayed rather than the word ‘NULL’, which is what we query for. :woman_shrugging:

1 Like

Hello @code0957173269,

Yes, you are correct that Ø is the symbol being used for NULL values. This is specific to the setup here. For example, if you use DB Browser for SQLite, you can setup NULL values to display NULL.

The important thing to note is that zero 0, NULL and blank ‘’ are not the same.

By running a query in the exercise with the 3 different conditions, you will see the counts differ.

select count(*) from nomnom
 where health IS NULL;  --Returns 5 rows
select count(*) from nomnom
 where health = 0;  -- where health = zero returns zero
2 Likes

So when we see a “0” value in a column, or anywhere as a value, we do not necessarily know whether the value is null or zero, but we do know that it is not blank. And if we know what db browser we are using, and that it is capable of displaying “NULL” instead of “0” for NULL, we can change that if it suits us or whomever we want it to suit. Sorry for such seemingly dumb question, not being sarcastic, just want to know … thank you.

Hello @markregan7370338109 ,

It’s not a dumb question at all.

Yes, when you “see” a “0” in a value column, use a query with a WHERE condition to verify if it’s NULL or ZERO. You can’t rely on what you are viewing on the screen.

1 Like