The following code
import java.io.StringReader;
import net.sf.jsqlparser.JSQLParserException;
import net.sf.jsqlparser.parser.CCJSqlParserManager;
import net.sf.jsqlparser.statement.Statement;
import net.sf.jsqlparser.util.deparser.StatementDeParser;
public class SelectDeparserTest {
public static void main(String[] args) throws JSQLParserException {
String originalSQL = "SELECT * FROM BOB B RIGHT JOIN FRED F ON (B.C=F.C)";
System.out.println(originalSQL);
Statement parsed = new CCJSqlParserManager().parse(new StringReader(
originalSQL));
StringBuffer stringBuffer = new StringBuffer();
parsed.accept(new StatementDeParser(stringBuffer));
System.out.println(stringBuffer);
}
}
when run has the following output
SELECT * FROM BOB B RIGHT JOIN FRED F ON (B.C=F.C)
SELECT * FROM BOB AS BRIGHT JOIN FRED AS F ON (B.C = F.C)
notice that the de-parsed query (the second one) lacks a white space between the alias for BOB, i.e.: B and the keyword RIGHT. The same happens for LEFT, INNER, OUTER, FULL, and simply JOIN