Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 9th, 2004, 12:52 PM
Authorized User
 
Join Date: Jun 2003
Location: Gulfport, Ms, USA.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hcweb
Default Select Statement Exclusion

Is it possible to exclude records in an sql statement such as:
"SELECT * WHERE casenumber = casenumber AND casetype NOT 'DUI'"

I have a large database I have to query and I want to exclude a certain case type.
  #2 (permalink)  
Old August 9th, 2004, 01:33 PM
Friend of Wrox
 
Join Date: Aug 2003
Location: , , .
Posts: 205
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Certainly. I am not sure what database you are using or what your code looks like so I am not sure what difficulty you are using. I might point out you are missing a FROM clause in your sql statement, which I believe is almost always necessary. If you post some code, I might be able to give more pointers.

Yehuda
  #3 (permalink)  
Old August 9th, 2004, 02:27 PM
Authorized User
 
Join Date: Jun 2003
Location: Gulfport, Ms, USA.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hcweb
Default

Thanks. Basically, the code I listed was just a generalization. The exact query is:

  Dim objRS, objComm, strName
  strName = Replace(UCASE(Request.Form("name")), "'", "''")

  Set objComm = Server.CreateObject("ADODB.Command")
  objComm.ActiveConnection = strConnect
  objComm.CommandText = "SELECT name, case_number, case_subtype From ITDTRF01 WHERE name LIKE '" & strName & "%' " & _
                        "AND case_subtype NOT 'DUI'"
  objComm.CommandType = adCmdText
  Set objRS = objComm.Execute
  Set objComm = Nothing


("AND case_subtype NOT 'DUI'") This is the part that I'm questioning.
  #4 (permalink)  
Old August 9th, 2004, 03:03 PM
Authorized User
 
Join Date: Aug 2004
Location: Chicago, IL, USA.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

this should work:
AND NOT case_subtype = 'DUI'

  #5 (permalink)  
Old August 9th, 2004, 03:21 PM
Authorized User
 
Join Date: Jun 2003
Location: Gulfport, Ms, USA.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hcweb
Default

Ahhh... Had it backwards. Worked like a champ! I really appreciate the help!
  #6 (permalink)  
Old August 9th, 2004, 03:43 PM
Authorized User
 
Join Date: Aug 2004
Location: Chicago, IL, USA.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No problem, glad we could help.

  #7 (permalink)  
Old August 10th, 2004, 12:33 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Alternately, it can also be written as:

AND case_subtype <> 'DUI'

Cheers!

_________________________
- Vijay G
Strive for Perfection


Similar Threads
Thread Thread Starter Forum Replies Last Post
select Statement gregalb SQL Server 2000 3 January 15th, 2008 12:00 AM
select statement help... RinoDM SQL Server 2000 13 January 10th, 2008 08:34 PM
Select statement.. help please sarah lee SQL Server 2000 4 May 16th, 2007 09:13 AM
Select from another select statement to a repeater simsen ASP.NET 2.0 Professional 0 May 2nd, 2007 04:34 PM
select statement help RinoDM SQL Server 2000 2 January 16th, 2007 11:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.