0

Name column contains space.I tried to fetch the column rows which contains only names and should not return null values and empty values.But it return the column which contain white spaces. I tried:

select name,id from details where name is not null;

The above query return the data contains white spaces. how to eliminate the data that contain white space in it?

MrMisery
  • 406
  • 7
  • 19
Namburi Akhil
  • 29
  • 1
  • 8
  • did you checkout this answer looks similar https://stackoverflow.com/questions/6969315/mysql-query-to-return-rows-that-contain-whitespace – Umakanth Sep 20 '17 at 05:56

3 Answers3

0

try to use the NOT LIKE syntax ; change your query to the following:

select name,id from details where name is not null and name not like '% %'

you can check this answer.

MrMisery
  • 406
  • 7
  • 19
0

Try trim function:

select name,id from details where name is not null and trim(name) <> '';
Blank
  • 12,308
  • 1
  • 14
  • 32
0

This may work for you.

select name, id 
from details 
where name is not null and name !=""
Fabrizio
  • 7,603
  • 6
  • 44
  • 104
Abhishek Singh
  • 701
  • 6
  • 5