How to add new column to select statement with JSqlParser

279 Views Asked by At

This is my sql statement.

String sql = "select mydate from mytable";

How can i add new columns to it dynamically with JSqlParser?

For example i want to add "mylocation" column to my sql query:

String sql = "select mydate, mylocation from mytable";
1

There are 1 best solutions below

0
AudioBubble On BEST ANSWER

According to the documentation it should work like this:

Select select = (Select) CCJSqlParserUtil.parse("select mydate from mytable");
SelectUtils.addExpression(select, new Column("mylocation"));