Question
Best Practice
i have the following query to perform
<cfquery name="products" datasource="#client.dsn#"
username="#client.username#" password="#client.password#">
Select * from Products
where product='#product_add1#'
and product='#product_add2#'
and product='#product_add3#'
and product='#product_add4#'</cfquery>
What is the best way to code this if all 4 variables may not always be
present.
For example there may be 1 - 4 variables.
Can I do something like?
Select * from Products
where
('#product_add1#' IS NOT NULL and product='#product_add1#')
and ('#product_add2#' IS NOT NULL and product='#product_add2#')
and ('#product_add3#' IS NOT NULL and product='#product_add3#')
and ('#product_add4#' IS NOT NULL and product='#product_add4#')
<cfquery name="products" datasource="#client.dsn#"
username="#client.username#" password="#client.password#">
Select * from Products
where product='#product_add1#'
and product='#product_add2#'
and product='#product_add3#'
and product='#product_add4#'</cfquery>
What is the best way to code this if all 4 variables may not always be
present.
For example there may be 1 - 4 variables.
Can I do something like?
Select * from Products
where
('#product_add1#' IS NOT NULL and product='#product_add1#')
and ('#product_add2#' IS NOT NULL and product='#product_add2#')
and ('#product_add3#' IS NOT NULL and product='#product_add3#')
and ('#product_add4#' IS NOT NULL and product='#product_add4#')