|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
trying to use 'or' for multiple drop downs
Hey,
I am trying to set up a selection where a user can choose from one or multiple drop downs and choose as many within a box as they want. works fine if you only choose from one column, but if you choose from two columns, the 'and' can create a bad match (for instance family may not be in that order, therefore nothing is returned). I would like the user to be able to choose several orders and perhpas a family not included in that list. I tried 'or,' but I am not sure how to begin this in that there needs to be an intial statement to attach the 'or's to, but if I do this, then I will also get that as part of the 'or'. I want to use 4 columns here eventually. any help is greatly appreciated, bill here is the link http://161.55.120.152/ichweb/specframe.cfm here is the code <cfparam name="sortBy" default="PhylogenyCode"> <CFQUERY NAME="qryPhySelect" DATASOURCE="ichweb"> SELECT tblSpeciesDict.* FROM tblSpeciesDict WHERE tblSpeciesDict.gsid=tblSpeciesDict.gsid <cfif isdefined ("Session.order")> <cfif Session.order is not ""> <!--- preservesinglequote and session needed to pass string of phylogeny to taxa list. session. is session variable set in SetVariable.cfm ---> AND tblSpeciesDict.order in (#PreserveSingleQuotes(Session.order)#) </cfif> </cfif> <cfif isdefined ("Session.family")> <cfif Session.family is not ""> AND tblSpeciesDict.family in (#PreserveSingleQuotes(Session.family)#) </cfif> </cfif> ORDER BY #sortBy# </cfquery> <head> <title>Phylogeny Search Results</title> <link rel="stylesheet" type="text/css" href="iis2.css" title="default"> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <meta http-equiv="Content-Language" content="en-us" /> <meta name="keywords" content="Ichthyoplankton, information, system, early, life, history, northeast, pacific, bering sea, gulf of alaska, washington, oregon, california, coast, fishery, atlas, key, fish, larvae, eggs, juveniles" /> </head> <body id="list"> <h3>Sort list:<h3> | <a href="SearchListPhy.cfm.cfm?sortBy=tblSpeciesDict.GSID">Alphabetically</a> | <a href="SearchListPhy.cfm.cfm?sortBy=PhylogenyCode">Phylogenetically</a> | </h3> <h3>Choose taxa</h3> <cfif qryPhySelect.order is not "" or qryPhySelect.order is not ""> <cfoutput query = "qryPhySelect"> <a href="LHDataIll.cfm?GSID=#qryPhySelect.GSID#" target="SearchLH"> - #qryPhySelect.Genus# #qryPhySelect.Species#</a></div> </cfoutput> <cfelse> <div>No taxa met the search criteria</div> </cfif> |
|
#2
|
|||
|
|||
|
Looking at your example, you'll just have to try out different loops and parenthesis positions...something like:
select * from myTable where (firstField = '#form.choice#') OR (secondField = '#form.choice1#' OR secondField = 'form.choice2'#) Good luck. Brian
__________________
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 Last edited by kiteless : April 7th, 2005 at 01:44 PM. |
|
#3
|
|||
|
|||
|
thanks.
problem there is I am want to use 4 sets of drop downs eventually and the code very complicated and kind of rube golbergian, it seems like there should be a more straight forward way of doing this. maybe not. |
|
#4
|
|||
|
|||
|
Not really...SQL isn't optimized for these sorts of long and complex where clauses. Remember that in many cases, what seems like it should be relatively simple can require a very complex SQL statement. You can fiddle with different loops and combinations of ORs and ANDs, or possibly look into doing full text indexing using Verity or some other text search tool.
|
|
#5
|
|||
|
|||
|
well, I think I may work with how I present the returned data then to avoid that code.
thanks for the info. bill |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > trying to use 'or' for multiple drop downs |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|