Is it possible to create a dynamic SQL statement based on user input using 3 textbox inputs?
var firstname = document.getElementById('firstname').value
var middle = document.getElementById('middle').value
var lastname = document.getElementById('lastname').value
var SQL
If all 3 fields are filled out:
SQL = "SELECT * FROM TABLE WHERE [Firstname] = '" + firstname + "' AND [Middle] = '" + middle + "' AND [Lastname] = '" + lastname + "'"
If 2 of the 3 fields are filled out:
SQL = "SELECT * FROM TABLE WHERE [Firstname] = '" + firstname + "' AND [Lastname] = '" + lastname + "'"
Is there a more concise way to handle this? Perhaps a shorter solution instead of evaluating each field and defining the SQL?
I was just curious, thought it wouldn't hurt to ask.
Jay