Solved

Question about where statement and not equal to results

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Coldfusion loop through a list of pairs name  -  value 3 66
coldfusion, javascript onclick url update 4 77
setup wamp server for first time 2 117
REGEX HELP 11 62
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

710 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