Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
reading a null value in a database (sql server)
Old 12-07-2005, 01:12 PM reading a null value in a database (sql server)
numbenator's Avatar
Webmaster Talker

Posts: 516
Location: London
Trades: 0
selecting all fields with a null value

hi,
Ihaev the below sql script,

SELECT t_newsID,dtm_date,str_title,str_body,flg_archived, flg_active,flg_NIB FROM tbl_News WHERE (flg_archived=0 or flg_archived=1)

I wish though to select all records where intBranchID = null thus not selecting those where intBranchID is a numeric value.

My selection doesnt seem to work if I use FROM tbl_News WHERE (flg_archived=0 or flg_archived=1) AND intBranchID= " "

How do i script this please.
My field in db is showing NULL

cheers

Steve
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
 
Register now for full access!
Old 12-07-2005, 02:48 PM
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
Trades: 0
This is how you check for null:
Code:
SELECT t_newsID,dtm_date,str_title,str_body,flg_archived, flg_active,flg_NIB 
FROM tbl_News 
WHERE (flg_archived=0 or flg_archived=1)
   AND intBranchID IS NULL
Anacrusis is offline
Reply With Quote
View Public Profile
 
Old 12-07-2005, 02:48 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
Nulls are special values. They are different to " ", which is a space, and they are even different to "", the empty string. To check for nulls use IS NULL:
WHERE (flg_archived=0 or flg_archived=1) AND intBranchID IS NULL

EDIT: Darn, only a few seconds between us,....
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Reply     « Reply to reading a null value in a database (sql server)
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.49570 seconds with 12 queries