On my screen, there are three input fields for capturing user search criteria. These fields are not mandatory and the input values are used as parameters in the SQL WHERE clause. Here is an example:
SELECT col1, col2, col3, col4
FROM table LEFT JOIN otherTable ON tableID = otherTableID
WHERE col1 LIKE :d1 AND col2 LIKE :d2 AND col3 LIKE :d3
User data is collected from the browser like this:
var inputField1= "%" + jQ.trim(jQ(".someclass").val()) + "%";
var inputField2= "%" + jQ.trim(jQ(".someclass").val()) + "%";
var inputField3= "%" + jQ.trim(jQ(".someclass").val()) + "%";
This data is then used in a Presto.ExecuteSql object:
Presto.ExecuteSql(
{
name: "SQL_Query",
params:
{
'd1': inputField1,
"d2": inputField2,
"d3": inputField3,
"d4": inputField4,
},
When users enter data in all three fields, the query returns the correct number of records. However, when they only fill in one field, the number of records returned is incorrect. How can I modify the WHERE clause to always get the right amount of records?