You have a syntax error right after your "From Contacts". If last_name is not null, then you'll have a problem because there is no "where" in that statement.
What you should have is: >From Contacts Where <CFIF last_name IS NOT ""> last_name LIKE '#last_name#'</cfif> (notice I took out "AND" here) Then, take out the four "where" after <cfif hockey_fan IS NOT ""> Nathan Chen -----Original Message----- From: Kent A. Orso [mailto:[EMAIL PROTECTED] Sent: Friday, March 17, 2006 2:28 PM To: CF-Newbie Subject: CFQuery from Database I'm trying to write a query that returns results on a database query after a user enters any information for a contact by entering any of the following in the form page: Last Name City County Neighborhood hockey_fan (Select from List Yes/No) Soccer_fan (Select from List Yes/No) Baseball_Fan (Select from List Yes/No) Basketball_Fan (Select from List Yes/No) The code that is generating errors: <cfquery name="contacts" datasource="cdb"> SELECT last_name, city, county, neighborhood, hockey_fan, soccer_fan, baseball_fan, basketball_fan FROM Contacts <CFIF last_name IS NOT ""> AND last_name LIKE '#last_name#' </CFIF> <cfif city IS NOT ""> AND city LIKE '#city#' </cfif> <cfif county IS NOT ""> AND county LIKE '#county#' </cfif> <cfif neighborhood IS NOT ""> AND neighborhood LIKE '#neighborhood#' </cfif> <cfif hockey_fan IS NOT ""> WHERE hockey_fan = 'YES' </cfif> <cfif soccer_fan IS NOT ""> WHERE soccer_fan = 'YES' </cfif> <cfif baseball_fan IS NOT ""> WHERE baseball_fan = 'YES' </cfif> <cfif hockey_fan IS NOT ""> WHERE hockey_fan = 'YES' </cfif> ORDER BY last_name </CFQUERY> I'm not sure why I can't seem to get a return when the user enters a last name of Smith, and YES to Hockey Fan and Yes to Baseball fan. Thanks for any help in advance, kent ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Message: http://www.houseoffusion.com/lists.cfm/link=i:15:1718 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/15 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:15 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
