Skip to content

Instantly share code, notes, and snippets.

@mhenke
Created November 12, 2013 19:43
Show Gist options
  • Save mhenke/7437380 to your computer and use it in GitHub Desktop.
Save mhenke/7437380 to your computer and use it in GitHub Desktop.
awesome query
<CFQUERY DATASOURCE='#DataSource#' USERNAME='#DataUserName#' PASSWORD='#DataPassWord#' NAME="output">
<cfif isdefined("variable.csd_id")>
select h.csm_id, h.csh_id, h.csc_id, h.css_id, h.csd_id, h.PageTitle, h.WebText, h.Keywords, h.RightBarDisplay, h.pageURL
from chambersitedetail h
where h.csd_id = <cfqueryparam cfsqltype="integer" value="#variable.csd_id#"> and h.csm_id = 1
<cfelseif isdefined("variable.css_id")>
select h.csm_id, h.csh_id, h.csc_id, h.css_id, h.PageTitle, h.WebText, h.Keywords, h.RightBarDisplay, h.pageURL
from chambersitesubcategory h
where h.css_id = <cfqueryparam cfsqltype="integer" value="#variable.css_id#"> and h.csm_id = 1
<cfelseif isdefined("variable.csc_id")>
select h.csm_id, h.csh_id, h.csc_id, h.PageTitle, h.WebText, h.Keywords, h.RightBarDisplay, h.pageURL
from chambersitecategory h
where h.csc_id = <cfqueryparam cfsqltype="integer" value="#variable.csc_id#"> and h.csm_id = 1
<cfelseif isdefined("variable.csh_id")>
select h.csm_id, h.csh_id, h.PageTitle, h.WebText, h.Keywords, h.RightBarDisplay, h.pageURL
from chambersiteheader h
where h.csh_id = <cfqueryparam cfsqltype="integer" value="#variable.csh_id#"> and h.csm_id = 1
<cfelse>
select h.csm_id, h.PageTitle, h.WebText, h.Keywords, h.RightBarDisplay, h.pageURL
from chambersitemaster h
where h.csm_id = 1
</cfif>
</CFQUERY>
@mhenke
Copy link
Author

mhenke commented Nov 12, 2013

using username, password.

using cfelseif instead of switch

@chrishough
Copy link

Love this. Great find.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment