|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Pulling results from 1 Text field and 2 Select Lists
I am trying to allow for selecting from a text box and two drop down lists. An individual could type in any part of a Last Name and select one choice from each of two Select lists. The result set should determine only those results that apply to each of the choices.
The three fields, LName, County, and Practice are all in the same table. The results are coming back accurately when I submit one field but not when I submit two or more. I am probably missing something very obvious to everyone but any help would be appreciated. <!--- Get Lawyer list from database ---> <CFQUERY NAME="LocateLawyer" DATASOURCE="Lawyer"> SELECT * FROM tblLawyers WHERE 0=0 <!--- Search by last name ---> <CFIF FORM.LName IS NOT ""> AND LName LIKE '%#FORM.LName#%' </CFIF> <!--- Search by county ---> <CFIF FORM.County IS NOT ""> AND County1 LIKE '%#FORM.County#%' OR County2 LIKE '%#FORM.County#%' OR County3 LIKE '%#FORM.County#%' OR County4 LIKE '%#FORM.County#%' </CFIF> <!--- Search by practice ---> <CFIF FORM.Practice IS NOT ""> AND Practice1 LIKE '%#FORM.Practice#%' OR Practice2 LIKE '%#FORM.Practice#%' OR Practice3 LIKE '%#FORM.Practice#%' OR Practice4 LIKE '%#FORM.Practice#%' </CFIF> ORDER BY LName </CFQUERY> |
|
#2
|
|||
|
|||
|
Try wrapping each set of WHERE criteria in parenthesis to ensure that the database is dealing with each one as it's own unit...something like this maybe:
<!--- Get Lawyer list from database ---> <CFQUERY NAME="LocateLawyer" DATASOURCE="Lawyer"> SELECT * FROM tblLawyers WHERE 0=0 <!--- Search by last name ---> <CFIF FORM.LName IS NOT ""> AND (LName LIKE '%#FORM.LName#%') </CFIF> <!--- Search by county ---> <CFIF FORM.County IS NOT ""> AND (County1 LIKE '%#FORM.County#%' OR County2 LIKE '%#FORM.County#%' OR County3 LIKE '%#FORM.County#%' OR County4 LIKE '%#FORM.County#%') </CFIF> <!--- Search by practice ---> <CFIF FORM.Practice IS NOT ""> AND (Practice1 LIKE '%#FORM.Practice#%' OR Practice2 LIKE '%#FORM.Practice#%' OR Practice3 LIKE '%#FORM.Practice#%' OR Practice4 LIKE '%#FORM.Practice#%') </CFIF> ORDER BY LName </CFQUERY>
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Pulling results from 1 Text field and 2 Select Lists |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|