1 | For example, in the following code, a series of CFIF tags determine which SQL statements to append to the base SQL SELECT statement: |
2 | <CFQUERY NAME="EmpList" DATASOURCE="CF 3.0 Examples"> |
3 | SELECT * FROM Employees WHERE 0=0 |
4 | <CFIF #LastName# is not ""> |
5 | AND LastName = '#LastName#' |
6 | </CFIF> |
7 | <CFIF #FirstName# is not ""> |
8 | AND FirstName LIKE '%#FirstName#%' |
9 | </CFIF> |
10 | </CFQUERY> |
11 | Tip: The WHERE 0=0 clause has no impact on the query submitted to the database. But if none of the conditions is true, it ensures that the WHERE clause does not result in a SQL syntax error. |