query none null values in mysql

I tried to implement the following mysql command try to get rows with none null values,

here is the table tbtext:

  id       text
     1 
     2     number2
     3     number3
     4     


   create table tbtext(
     id unsigned int auto_increment primary key,
     text char(7)
      )

I tried select * from tbtext where text is not null, but it returns the whole rows and doesn’t return row 3 and row 4. I am new to mysql, can anyone help me with it, thanks in advance.

Answer

I’m assuming text contains empty strings, and not NULL. The best thing to do would be to replace those empty strings with NULL, but you could also use this query :

-- ...
WHERE text <> '';

Please note however that empty strings are information, where NULL means lack of information. You should definitely not have empty strings if that’s not what you’re trying to do.