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 ?

shibly
  • 11,690
  • 35
  • 99
  • 163
Eme Emertana
  • 551
  • 8
  • 14
  • 28

6 Answers6

4

Check whether it is null or empty string.

 Select * FROM Items WHERE Extra IS NULL OR Extra = ''
xdazz
  • 154,648
  • 35
  • 237
  • 264
  • 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
  • 155,156
  • 41
  • 207
  • 295
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
shibly
  • 11,690
  • 35
  • 99
  • 163
0
Select * 
FROM Items 
WHERE Extra IS NULL
Mahmoud Gamal
  • 75,299
  • 16
  • 132
  • 159
0

If you by empty mean NULL...

Select * FROM Items WHERE Extra IS NULL
the Tin Man
  • 155,156
  • 41
  • 207
  • 295
Daniel Persson
  • 2,131
  • 1
  • 17
  • 24
-1

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

SELECT * FROM `Items` WHERE `Extra` < 1;
feeela
  • 27,811
  • 6
  • 58
  • 68
  • 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