<<Previous: Embedded Parameters | ↑Up: Using Parametric Search SQL | Next>>: Group By |
The SQL Query Clause has the additional feature that parameters are
optional: if a given $qp
... parameter is not provided a value
at search time, or is given an empty value, then that part of the SQL
clause is automatically dropped. This allows the SQL Query Clause to
be made as complex as needed for the most-specific possible query,
yet automatically "fall back" to a simpler version (or none at all)
if certain parts are not needed.
For example, a profile with the fields Color, Price and Quantity might have its SQL Query Clause set to:
Color = $qpDesiredColor and Price <= $qpMaxPrice and
(Quantity >= $qpMin and Quantity <= $qpMax)
This will search all three fields, if all of the $qp
... parameters
are provided. However, if say only qpMaxPrice and qpMin
were provided non-empty values at search time, the equivalent
search clause actually used would effectively be just:
Price <= $qpMaxPrice and (Quantity >= $qpMin)
This feature allows tremendous flexibility in users' searches. One search form can now handle a full spectrum of queries - from complex drill-down queries with many parameters to simple text searches - without reconfiguration by the admin or "knob-turning" by the search user. The profile will simply search for the fields filled in, no more no less.
<<Previous: Embedded Parameters | ↑Up: Using Parametric Search SQL | Next>>: Group By |