Solved

Question about where statement and not equal to results

Posted on 2007-04-10
5
595 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 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

Interactive Way of Training for the AWS CSA Exam

An interactive way of learning that will help you visualize core concepts so that you can be more effective when taking your AWS certification exam.  Built for students by a student to help them understand the concepts that they are being taught.

Question has a verified solution.

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

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.
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
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…

632 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