Thanks Torch7 for the added info.
Do you think you could show the coding for the <cfif> statement you talked about?
If you could that would be great for the ones that are new to Coldfusion, I'm one of them
Sure:
Using the CFIF statements to check against parameters that are defined in the form, and create a Where statement based upon present Parameters.
In ColdFusion there is no need to give a parameter a value, and it can remain blank; which will work to our advantage on this example. So I would remove the 1's from the default values.
<cfparam name="FORM.Artist" default="">
<cfparam name="FORM.Title" default="">
WE CAN NOW Combine the searches Into One Query.
<cfquery name="Search" datasource="MusicList">
SELECT *
FROM MusicList
WHERE 0 = 0
<CFIF Form.Artist IS NOT "">
AND Artist LIKE '%#Form.Artist#%'
</CFIF>
<CFIF FORM.Title IS NOT "">
AND Title LIKE '%#Form.Title#%'
</CFIF>
</cfquery>
Now the Query will search for whatever field is present in the form, and even search for Artist and Title if they are both present...
This could be to your advantage if you have two tracks with the same title, but different artists.
Also... I would get intot the habit of writing my SQL a little differently, because it can get confusing, when the Queries get more complicated.
1.) I would use the tableName.fieldName method to define everything in my query... This cuts down on confusion when you have to select from multiple tables.
IE: SELECT table1.artist, table2.artist, table2.song
FROM table1, table2
WHERE 0 = 0
AND table1.artist = table2.artist;
This is still a pretty simple SQL statement but you see how things could get confusing once you start getting into Inner and Outer joins.
2.) I would define an Application Scope variable for the Datasource Name
IE: <CFQUERY NAME="Query" DataSource="#application.DSN#">
IF you ever begin to write more complicated applications, and the Database name needs to change you change it in one place. The application.cfm
3.) I would get in the habit of using <cfqueryparam> tag around all variables passed to a query for a couple of reasons.
1.) its more secure
2.) it speeds up your query.
IE: WHERE Title LIKE <cfqueryparam value=�%#Form.Title#%� cfsqltype=�cf_sql_char�>
I hope my suggestions weren't too weighty...but chime in and I will explain further.