I need your help.
I'd like to write a function that would detect and determine the operator (LIKE/=) to use in an SQL string
Example:
var input_string = "SELECT * from table WHERE [FIRSTNAME]"
var input_text = document.GetElementbyId('firstname').value
if 1 of the 4 possible combinations are met from the given input_text then the operator value will be "LIKE", else it is an equal sign (=)
1.) At the start of the string: %firstname
2.) somewhere in the string itself: first%name
3.) At the end of the string: firstname%
4.) at both ends of the string: %firstname%
Example:
var output_string = input_string + analyze(input_text) '+input_text+'
var output_string examples:
SELECT * FROM TABLE WHERE [FIRSTNAME] LIKE '%firstname%'
SELECT * FROM TABLE WHERE [FIRSTNAME] LIKE '%first%name'
SELECT * FROM TABLE WHERE [FIRSTNAME] LIKE 'firstname%'
SELECT * FROM TABLE WHERE [FIRSTNAME] LIKE '%firstname%'
else
SELECT * FROM TABLE WHERE [FIRSTNAME] = 'firstname'