The '' does not help in your query, that are wrapped around your where clause:
SELECT service_population,agency,city,state,salary_status FROM internships WHERE service_population=''Children'' ORDER BY agency ASC Not sure how you are passing them in the form, but you want it to read: SELECT service_population,agency,city,state,salary_status FROM internships WHERE service_population='Children' ORDER BY agency ASC Robert Bailey Software Engineer 813-230-9967 \\ mobile [EMAIL PROTECTED] www.recruitmax.com -----Original Message----- From: Daniel Kessler [mailto:[EMAIL PROTECTED] Sent: Monday, January 10, 2005 1:10 PM To: CF-Talk Subject: Building a SQL WHERE clause I'm doing my first Search utility: http://hhp.umd.edu/studentservices/internships.cfm I'm trying to build a WHERE clause in CF where it check to see if a form field is part of a search and if it is, then it builds into the WHERE string. Unfortunatley when I do, I get the error, "SQL command doesn't end properly" after clicking Search. Here's some of the code: <cfif structKeyExists(Form,"service_population") OR structKeyExists(Form,"agency") OR structKeyExists(Form,"city") OR structKeyExists(Form,"state") OR structKeyExists(Form,"salary_status")> <cfoutput> <--- setup a search ---> <cfset find_text = "WHERE "> <cfif structKeyExists(Form,"service_population")> <!--- <cfset find_text ="WHERE service_population='children'">---> <cfset find_text ="#find_text#service_population='#Form.service_population#'"> </cfif> <cfquery name="getSearchItem" datasource="dpch"> SELECT service_population,agency,city,state,salary_status FROM internships #find_text# ORDER BY agency ASC </cfquery> </cfoutput> <cfelse> <--- setup some presets ---> <cfset service_population = ''> <cfset agency = ''> <cfset city = ''> <cfset state = ''> <cfset salary_status = ''> </cfif> Also, if someone can just point me to a tutorial on this, then that'd be fine. Really, any help would be appreciated. -- Daniel Kessler Department of Public and Community Health University of Maryland Suite 2387 Valley Drive College Park, MD 20742-2611 301-405-2545 Phone www.phi.umd.edu ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:189826 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

