Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | 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 November 11th, 2003, 07:02 PM
Registered User
 
Join Date: Aug 2003
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL Statements

How do you word the WHERE portion of a SQL statement to omit records. For instance I want to omit records where the records contain a Name entry matching the password. I tried
strSQL = "SELECT * FROM Gift WHERE Name NOT 'Password' ORDER BY Name"
and it does not work.
Everything I find of for LIKE or =

Is it that Name is one of the reserved phrases?

Reply With Quote
  #2 (permalink)  
Old November 11th, 2003, 07:24 PM
Registered User
 
Join Date: Aug 2003
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well can I reply to my own topic. Just when I get frustrated and ask for help I find the answer. In case anyone else is looking for help with this, I did change the field name to Person and then remembered that I couldn't just use 'Password' in the statement or it would look for a person named Password. This is the string that works:
strSQL = "SELECT * FROM Gift WHERE Person NOT LIKE '" & Password & "' ORDER BY Person "

Reply With Quote
  #3 (permalink)  
Old November 11th, 2003, 09:30 PM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Marmer, while your solution will work it is not the intended purpose of the like statement.
strSQL = "SELECT * FROM Gift WHERE Person <> '" & Password & "' ORDER BY Person "
would be a better solution.
Like and not like are better for finding matches when the entire string is not known
eg Person like '%son'
would return johnson, jackson, gibson as % is a none or many wildcard.
I do not know of the performance effects of using like/not like instead of =/<> but I'm sure there will be some.
It would be better to use <> if others will be reading your code.

======================================
They say, best men are moulded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
Reply With Quote
  #4 (permalink)  
Old November 13th, 2003, 01:42 AM
Registered User
 
Join Date: Aug 2003
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks! For some reason, I didn't make the transfer. I use that to check to see that a form field has information, but have trouble thinking of it as a word comparison instead of a number comparison. I've used your string and it works fine. This is just for a family Christmas Wish List that I will make available for my immediate family, but I still need to form the habit of doing it correctly.

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
Using COLLATE in SQL SELECT Statements sudhakaratp SQL Server 2000 8 September 6th, 2018 01:16 PM
Can i use asp within sql statements knight Classic ASP Databases 43 May 24th, 2007 09:32 AM
CASE Statements in T-SQL atcs2152 SQL Server 2000 3 April 28th, 2006 10:53 AM
Plz Help - Nested SQL Statements? esemerda SQL Language 2 February 28th, 2005 06:41 AM
sql statements and stored proc. HOW????? xristina MySQL 3 October 24th, 2004 07:12 AM



All times are GMT -4. The time now is 12:43 PM.


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