Null value in SQL statement

Posted on 2003-10-27
Medium Priority
Last Modified: 2010-05-03

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) = ''))"

Question by:ray14

Accepted Solution

j_a_delooze earned 300 total points
ID: 9630187

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


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

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 200 total points
ID: 9630538

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


Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

586 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