Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > ASP Forms
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms 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
 
Old August 22nd, 2003, 02:58 PM
Authorized User
 
Join Date: Jul 2003
Posts: 41
Thanks: 0
Thanked 1 Time in 1 Post
Default can't use = and don't want to use LIKE in WHERE

sSQL = "SELECT * " & _
 " FROM MasterTableCfoapal2" & _
 " WHERE ACCOUNT LIKE '%" & Request.Form("search_string") & "%'" & _
 " or SUB LIKE '%" & Request.Form("search_string") & "%'" & _
 " or Division LIKE '%" & Request.Form("search_string") & "%'" & _
 " or DIRECTOR = '%" & Request.Form("search_string") & "%'" & _
 " ORDER BY ACCOUNT, SUB"
set rs = Connect.Execute(sSQL)

For some reason when I look for a "DIRECTOR" I always get no replies. Do I need to do something like chomp the string before checking it? How? I can use "LIKE" instead of "=" but then I get some items from other parts of the search that I don't want.

 
Old August 22nd, 2003, 03:42 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

If you want to look for a specific "DIRECTOR" you should use = and ommit the % in the search string. If you want to use % you have to use LIKE. The reason you get no rows returned is that when you use = the search is looking for the literal character "%" in the values, not using is as a wildcard the way LIKE uses it.









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