I am working on a java app that utilizes PreparedStatement.
SELECT FIELD1, FIELD2 FROM MYTABLE WHERE (FIELD1='firstFieldValue' OR FIELD1='' or 'firstFieldValue'='');
firstFieldValue is a parameter. And it is necessary to check that its value is empty in SQL.
I created a prepared statement with the following parametrized SQL:
SELECT FIELD1, FIELD2 FROM MYTABLE WHERE (FIELD1=? OR FIELD1='' or ?='');
and I set values as follows:
preparedStatementInstance.setString(1, this.firstFieldValue);
preparedStatementInstance.setString(2, this.firstFieldValue);
This way does not work. Execution fails.
I think the prepared statement SQL is wrong.
How can I fix the SQL for prepared statement for this case?
Just check it in java.