Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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.
Reply With Quote
  #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
Reply With Quote
  #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.
Reply With Quote
  #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'

Reply With Quote
  #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!
Reply With Quote
  #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.

Reply With Quote
  #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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 03:42 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.