473,396 Members | 2,037 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Null Value in NOT IN condition.

4
Hi Guys,

I have this following table testin:
SQL> desc testin
Name Null? Type
------------------------------- -------- ----
NAME VARCHAR2(20)
SEX NOT NULL CHAR(1)

These are the records available in testin table:
SQL> SELECT * FROM TESTIN;

NAME S
-------------------- -
GABBIE F
F
F
TINA F
GLADIA F
KEVIN M
GIVANI M
JOHN M
SHIVA M

9 rows selected.

There are 2 rows for which NAME column has NULL value. But when i give the following query which has a NULL value in it, no rows are selected.


SQL> SELECT * FROM TESTIN WHERE NAME NOT IN('GABBIE','GLADIA',NULL);

no rows selected

and if take the NULL from the NOT IN condition, i get the follwoing results.

SQL> SELECT * FROM TESTIN WHERE NAME NOT IN('GABBIE','GLADIA');

NAME S
-------------------- -
TINA F
KEVIN M
GIVANI M
JOHN M
SHIVA M

The records with Null Values are not Returned.

Somebody please explain me this.

Thanks in Advance,

Regards,
Shiva
Sep 22 '05 #1
3 9281
:) Please type the query as follows:

SQL> SELECT * FROM TESTIN WHERE NAME NOT IN('GABBIE','GLADIA') and NAME NOT NULL;

NULL is the value which cannot be included as IN..... so always use it as given above.....


:)
Sep 29 '05 #2
shiva
4
Thanks Richa, I got it and understood now!!
Oct 7 '05 #3
masha
1
Hi,

pls read the following: http://technet.microsoft.com/en-us/library/ms177682.aspx

test_expression [ NOT ] IN
( subquery | expression [ ,...n ]
)
the result must be from the same data type as test_expression. if you getting NULL results - you must cust them to the expected data type.

The alternative is to use left outther join which will return you all results, including NULLs.

Masha
Jul 15 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Chris | last post by:
I have tableA, defined as: field1 varchar2(10), field2 varchar2(10), field3 varchar2(10) I have host variables defined as: v1 pic x(10) varying v2 pic x(10) varying
3
by: John Morgan | last post by:
In an SQL statement which concatenates several fields I get a null value returned if any one of the fields are null. Is this to be expected? For example : SELECT tblMember.memberAddress + '...
2
by: Joel | last post by:
Hi, I added a field to my company table (PBV_rstCompany.Fields("Installer")) the default value of the field is Null. I place this If statement and it doesn't work If...
19
by: Baldur Norddahl | last post by:
Hi, How come "X=null" is not the same as "X is null"? I got a few selects with queries like this: select * from foo where customer=#customer# or (#customer# is null and customer is null) ...
3
by: Johm | last post by:
I cannot define the Null situation in my code. I need the condition when the quantity in the field stock is Null.But i cannot do it.I can do it only with <=1 but then it means that the presence...
9
by: Steve Sargent | last post by:
Hi: I'm trying to debug the following code, and it keeps looping on the if statement: public static bool operator == (OnlineMemberNode first, OnlineMemberNode second) { if(first == null) {
4
by: John | last post by:
Hi, I'm writing a database programme with C# using a dataset. I want to set a DateTime for a particular field of a row to null (nulls are allowed for that column). When I use: ...
2
by: Jeff | last post by:
Hey I've bought the book "ASP.NET 2.0 website programming, Problem, Design, Solution" and some of its code examples is this code: protected static string ConvertNullToEmptyString(string input)...
2
by: Michael R | last post by:
Hi All. In a query one of field's conditions is a function value. Condition: fFunc() fFunc() function can sometimes return a Null value. If it does, the query selects no records, which it...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.