?
Solved

Question about where statement and not equal to results

Posted on 2007-04-10
5
Medium Priority
?
600 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 13

Accepted Solution

by:
usachrisk1983 earned 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

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

This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

719 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