Solved

Question about where statement and not equal to results

Posted on 2007-04-10
5
580 Views
Last Modified: 2013-12-24
Currently, all online requests are being displayed because I am using the following code:
<cfquery name="webdirectory" datasource="hr">
SELECT * FROM gradschool WHERE 0=0
order by id DESC

The documentation field contains several possibilities:  it is blank or contains one of the following terms:  delete, denied, approved.  I would like the delete requests not to show up; however when I use this code,

WHERE documentation <> 'delete'

the delete requests don't show up but neither do the empty - waiting to approved requested - which is bad.  Other then filling the empty field with a term, is there any code that will allow me to do this?

Thanks,
Deb
0
Comment
Question by:wwp_it
  • 3
5 Comments
 
LVL 13

Accepted Solution

by:
usachrisk1983 earned 500 total points
ID: 18883091
Your query should look like this:

select gradschool.*
   from gradschool
  where gradschool.documentation <> 'delete' or gradschool.documentation is null
0
 
LVL 20

Expert Comment

by:trailblazzyr55
ID: 18892422
you may want to try one of two things depending on your database and sql.

<cfquery name="webdirectory" datasource="hr">
SELECT * FROM gradschool
WHERE documentation != 'delete'
order by id DESC
</cfquery>

or...

<cfquery name="webdirectory" datasource="hr">
SELECT * FROM gradschool
WHERE documentation <> 'delete'
order by id DESC
</cfquery>

for a single table, you don't really need to prefix with an alias, and where 0=0 is not needed unless you have a dynamic WHERE clause and some or non of the WHERE conditions will be met.
0
 
LVL 20

Expert Comment

by:trailblazzyr55
ID: 18892440
usachrisk1983 already has demonstrated the code if you want to not show nulls as well.
0
 
LVL 20

Expert Comment

by:trailblazzyr55
ID: 18892470
sorry misread, usachrisk1983's code will return null records in the "documentation" field, you don't really need to specify you want nulls, they will come back with everything else.
0
 

Author Comment

by:wwp_it
ID: 18900616
select gradschool.*
   from gradschool
  where gradschool.documentation <> 'delete' or gradschool.documentation is null

Chris,

Why do you use the period after gradschool in the select line?
Deb
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

705 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now