Wrox Programmer Forums
|
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
 
Old February 13th, 2010, 05:22 AM
Authorized User
 
Join Date: Dec 2009
Posts: 85
Thanks: 16
Thanked 0 Times in 0 Posts
Default search result - coacentanating?

Hi there

If I wanted to do a search by ‘firstname surname’ what would the sql be like? Would I need to join them with a +?

For example I want to search for ‘david smith’ rather than just ‘smith’

At the moment it’s like this:

if Trim(request("txtSearch")) <> Empty then

SQLSearch = SQLSearch & " product.firstname LIKE '%"& Replace(request("txtSearch"), "'", "''") &"%' OR "
SQLSearch = SQLSearch & " product.productname LIKE '%"& Replace(request("txtSearch"), "'", "''") &"%' OR "

etc

But if I wanted to search by product.firstname and product.surname as one?

Would it be something like this:

SQLSearch = SQLSearch & " product.firstname LIKE '%"& Replace(request("txtSearch"), "'", "''") &"%' + product.productname LIKE '%"& Replace(request("txtSearch"), "'", "''") &"%' OR "
SQLSearch = SQLSearch & " product.firstname LIKE '%"& Replace(request("txtSearch"), "'", "''") &"%' OR "
SQLSearch = SQLSearch & " product.surname LIKE '%"& Replace(request("txtSearch"), "'", "''") &"%' OR "

etc?

Thanks in advance.
 
Old February 15th, 2010, 08:01 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Correct, If you want to search by firstname or surname then
Code:
SearchText = Trim(request("txtSearch")) & ""
SearchText = Replace(SearchText, "'", "''")

if SearchText <>"" then
 'If you want to search for firstname or last name then:
 SQLSearch = SQLSearch & "(firstname LIKE '%"& SearchText  &"%' OR surname LIKE '%"& SearchText  &"%') " 
 
 'If you want to combine these two fields then (Remove space beteen first/surname if require.
 SQLSearch = SQLSearch & "(firstname + ' ' + surname LIKE '%"& SearchText  &"%') " 
end if
__________________
Om Prakash Pant
Click the "Thanks" button if this post helped you.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Paging for the search result ssvas BOOK: Beginning SharePoint 2007: Building Team Solutions with MOSS 2007 ISBN: 978-0-470-12449-9 0 November 27th, 2008 03:02 AM
Search Result batott ASP.NET 2.0 Professional 1 June 5th, 2008 08:39 AM
Display Search Engine result in table using JSP sbc789 JSP Basics 3 December 3rd, 2007 11:35 PM
helph with search n disp on result to link Calibus Classic ASP Databases 3 July 8th, 2004 01:13 PM
how to search on multiple sites and showing result cyberviral Classic ASP Basics 0 March 23rd, 2004 09:08 AM





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