Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account



Photo

SQL Query - need to return null values

- - - - -

  • Please log in to reply
1 reply to this topic

#1
footballking3420

footballking3420

    Horror & Metal purist

  • Member
  • PipPip
  • 119 posts
  • Joined 13-June 06
I can't for the life of me remember how to return both null and non-null values in a SQL Query. I'll go ahead and post what I have:

SELECT OrdNo, OrdDate, Employee.EmpNo, EmpFirstName, EmpLastName
FROM OrderTbl JOIN Employee
ON OrderTbl.EmpNo = Employee.EmpNo
WHERE OrdDate = '01/23/07'

I have two rows where the EmpNo is null, but there is still data I need to retrieve from it.


How to remove advertisement from MSFN

#2
teratera

teratera
  • Member
  • 1 posts
  • Joined 05-November 08
SELECT OrdNo, OrdDate, Employee.EmpNo, EmpFirstName, EmpLastName
FROM OrderTbl JOIN Employee
ON OrderTbl.EmpNo = Employee.EmpNo
WHERE OrdDate = '01/23/07' or OrdDate IS NULL

Do not use ISNULL to find NULL values. Use IS NULL instead. Note the space between IS and NULL

http://technet.micro...y/ms184325.aspx

====================================================================================================
=

I can't for the life of me remember how to return both null and non-null values in a SQL Query. I'll go ahead and post what I have:

SELECT OrdNo, OrdDate, Employee.EmpNo, EmpFirstName, EmpLastName
FROM OrderTbl JOIN Employee
ON OrderTbl.EmpNo = Employee.EmpNo
WHERE OrdDate = '01/23/07'

I have two rows where the EmpNo is null, but there is still data I need to retrieve from it.


Edited by teratera, 05 November 2008 - 10:54 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users