I want to add where condition to sql with JSqlParser, for example:
Before:
select * from test_table where a=1 group by c
After:
select * from test_table where a=1 and b=2 group by c
However, I cannot find any example codes.
I want to add where condition to sql with JSqlParser, for example:
Before:
select * from test_table where a=1 group by c
After:
select * from test_table where a=1 and b=2 group by c
However, I cannot find any example codes.
One solution would be:
First, you have to parse the existing SQL. Using this PlainSelect cast you are getting access to the where clause of your statement, at least at the object it holds it.
The where expression is generated using the convenience method
CCJSqlParserUtil.parseCondExpression.The output of those statements is: