Solved

Null value in SQL statement

Posted on 2003-10-27
2
218 Views
Last Modified: 2010-05-03
Hi,

please ammend this SQL code to select records if A1 and A2 fields are Null value. I used '' but it doesn't give me correct answer.

"select * From Table1 Where (((Table1.A1) = '')  And ((Table1.A2) = ''))"

Thanx
0
Comment
Question by:ray14
2 Comments
 

Accepted Solution

by:
j_a_delooze earned 75 total points
ID: 9630187
try:

SELECT * FROM [Table1] WHERE (([Table1].[A1] IS NULL) AND ([Table1].[A2] IS NULL));

-or-

SELECT * FROM [Table1] WHERE (([Table1].[A1] = NULL) AND ([Table1].[A2] = NULL));
0
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 50 total points
ID: 9630538
j_a_delooze,

If this is MS SQL Server the second solution will not return any values.  Reason: Null <> Null

Anthony
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question