So I've got me a good ol' fashioned sql query conundrum. Doing a site in with coldfusion and it comes to a page and does a query with MySQL and returns some values that set up the page. It brings back multiple products, and what I want to do is allow the user to be able to drill down those products to a more refined product base. So they're air conditioners, the original query returns the entire list of available models, I want them to be able to select some different options to have... 5 or less show up instead of 41. So here's what i've got...
HTML Code:
<cfquery name = "getwindowmodels" datasource="#Request.dsn#">
SELECT model, short_desc, unit_link, unit_image_s
<!---Begin the decision to 're-ask' query with a single dropdown chosen, By
the way this is working, but very much proof of concept and i'm stuck on
how to incorporate more than one dropdown decision into the 'modified'
SQL statement.--->
<cfif IsDefined('form.submit')>
FROM rac_units
WHERE <cfoutput>#form.btu_range#;</cfoutput>
<!---
If 'decision div form' submit button isn't detected, then just ask the basic
SQL question to get the entire list.
--->
<cfelse>
FROM rac_units;
</cfif>
</cfquery>
So i guess what my question is, is if you know coldfusion... does this seem efficient? Or should I be using a if statement to decide on using another query instead of trying to modify one (like i am doing now). Also... what is the correct syntax for doing a AND OR command inside a WHERE question in SQL?
i.e WHERE column = value AND OR column = value AND OR column = value
So if any one of the three values are blank it will ignore them and use what it has to 'requery' the query.