We help IT Professionals succeed at work.
Get Started

Return a result if Query brings back nothing

Last Modified: 2012-05-09
Hi Everyone,

I have a query that I am running that I would like to understand how to return a result if the query brings back nothing.

At the moment it looks like this ...

FROM WF_Milestones
WHERE EFOLDERID = '123456'AND ID = ('123' - 1)

What I am doing here is querying the ID column from the previous record to bring back a date, if this has null in the date column then it brings back the current date. This works as I want it to.

However if the record I am querying is the first in the table or recordset, then it does not return anything. How can I make sure it always brings back a result, preferably the current date?

Thanks in advance everyone!

Watch Question
C# ASP.NET Developer
Top Expert 2010
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE