Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > Adobe Web Programming > Dreamweaver (all versions)
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Dreamweaver (all versions) 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 May 6th, 2006, 06:39 AM
Authorized User
 
Join Date: Aug 2005
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help with code to filter through database.

Hey there, I have the following code that works just fine, but I would like for it to filter/search through another category.

"SELECT SupplierName, Location, ShortDescription, TimberSpecies, CategoryTitle, Country
FROM Query1
WHERE TimberSpecies LIKE '%" + Replace(rsSearchResult__MMColParam, "'", "''") + "%' AND CategoryTitle LIKE '%" + Replace(rsSearchResult__MMColParam2, "'", "''") + "%' AND Location LIKE '%" + Replace(rsSearchResult__MMColParam3, "'", "''") + "%'
ORDER BY SupplierName"

In this code I would like for the search to also search all customers with the "Retail-Trade" category. "Wholesale" I want to exclude.

Table Name: Query1
Column Name: BusinessType
Record or Category Names: Retail-Trade & Wholesale.

Is this possible with the code I have supplied?

Thanks again.

Mally.
 
Old May 8th, 2006, 09:33 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Mally,

You can use the OR operator in your code, like this:

SELECT SupplierName ..... FROM Query1 WHERE CategoryTitle LIKE
        '%SomeValue%' OR CategoryTitle LIKE '%SomeOtherValue%'

This should return records where the CategoryTitle contains either SomeValue or SomeOtherValue (or both)

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old May 22nd, 2006, 05:34 AM
Authorized User
 
Join Date: Aug 2005
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Imar, yest it did help.

Mally

 
Old May 26th, 2006, 05:15 PM
Registered User
 
Join Date: May 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

So how would you go about coding on a recordset to ignore a drop-down menu if nothing is selected so no data is shown and still show data from the other combo menus base on what was selected?

Thnks


 
Old May 27th, 2006, 02:44 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi sunvalley,

Can you please start a new thread when you post a question not related to the initial question? Makes it easier for everyone to find and manage this thread.

That said, can't you create a WHERE clause dynamically based on what is selected??
E.g.

sqlWhere = " WHERE SomeCondition"
If Request.Form("SomeDropDown") <> "" Then
  sqlWhere = sqlWhere & " SomeField = " % Request.Form("SomeDropDown")
End If

If Request.Form("SomeOtherDropDown") <> "" Then
  sqlWhere = sqlWhere & " SomeOtherField = " % Request.Form("SomeDropDown")
End If


This way, you effectively ignore the drop downs that don't have a value.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004





Similar Threads
Thread Thread Starter Forum Replies Last Post
Detach an in-use database via code Sma_Soft SQL Server 2000 0 August 14th, 2007 10:20 AM
FUNCTION FILTER DATA FROM SQL DATABASE abofoma00 Javascript 1 November 21st, 2005 11:28 AM
Filter HTML Code in XSL Teo916 XSLT 2 September 24th, 2005 09:19 AM
code doesn't update database Lesviper Beginning VB 6 1 February 7th, 2005 10:18 AM
Compacting Access Database from code imaley Access 6 March 31st, 2004 05:33 PM





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