1

I need to retrieve columns of a row that one of its data types is empty. Extra VARCHAR Extra has nothing in it

Show those with empty extra column

  Select * FROM Items WHERE Extra ?????

What should be the condition ?

cola
  • 12,198
  • 36
  • 105
  • 165
Eme Emertana
  • 561
  • 8
  • 14
  • 29

6 Answers6

4

Check whether it is null or empty string.

 Select * FROM Items WHERE Extra IS NULL OR Extra = ''
xdazz
  • 158,678
  • 38
  • 247
  • 274
  • 1
    Here's a good habit to get into... Put all ORs in parens. The first time you try to edit a `WHERE` clause with an `OR`, you'll appreciate them... – Alain Collins Sep 18 '12 at 17:30
2
select * from items where Isnull(extra,'')=''
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
1

If empty means "" or empty string then:

select * from items where extra="";

The length of empty string is zero/0 .

If empty means NULL then:

select * from items where extra is NULL;

The length of NULL is NULL.

If you want to read more, you can read these:

Community
  • 1
  • 1
cola
  • 12,198
  • 36
  • 105
  • 165
0
Select * 
FROM Items 
WHERE Extra IS NULL
Mahmoud Gamal
  • 78,257
  • 17
  • 139
  • 164
0

If you by empty mean NULL...

Select * FROM Items WHERE Extra IS NULL
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Daniel Persson
  • 2,171
  • 1
  • 17
  • 24
-1

Select empty varchar fields, with either an empty string or NULL in it:

SELECT * FROM `Items` WHERE `Extra` < 1;
feeela
  • 29,399
  • 7
  • 59
  • 71
  • If 'extra' is null, your express will return null, and no row will be returned. Plus it's typecasting everything, and is hard to read. – Alain Collins Sep 18 '12 at 17:29