|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Learn five alternative approaches for automating the delivery of Excel-based reports. Read all about it in the free whitepaper: “Automating Excel Reports: Five Approaches for Java Developers” Download Now!
|
|
#1
|
||||
|
||||
|
ignore search field if empty?
I have a search form with three fields that will search a MS SQL database. Two fields are text fields and one is a multiple select box. If no value is ever entered into a text field, I need to ignore it in the SQL query... The way it stands now, the query I am generating looks like this:
SELECT ItemID, Description, QuantityOnHand, ListPrice, Category FROM Merchandise WHERE ItemID = AND Description LIKE AND category IN(Bird,Cat) because it is looking for a value for the two text fields ItemID and Description, which have not been entered... Any solutions to this problem? THANKS IN ADVANCE!
__________________
Reinventing the wheel again Last edited by mateoc15 : April 8th, 2004 at 11:31 AM. |
|
#2
|
||||
|
||||
|
Furthermore... how would I get the search to return ALL rows if no criteria were entered? Just check each one with a CFIF and then do a SELECT * FROM... ?
|
|
#3
|
|||
|
|||
|
Something like:
SELECT ItemID, Description, QuantityOnHand, ListPrice, Category FROM Merchandise WHERE category IN(Bird,Cat) <cfif len( trim( form.myTextField ) )> AND ItemID = #form.myTextField# AND Description LIKE '#%form.myTextField%#' </cfif> |
|
#4
|
||||
|
||||
|
great... thanks!!!
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > ignore search field if empty? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|