public static void main(String[] args) {
//String sql = "select * from a";
// String sql = "select * from a limit 300";
String sql = "select * from (select * from b limit 1000) limit 400";
try {
SQLStatement stmt = SQLUtils.parseSingleMysqlStatement(sql);
if (stmt instanceof SQLSelectStatement) {
SQLSelectStatement selectStmt = (SQLSelectStatement) stmt;
SQLSelectQuery query = selectStmt.getSelect().getQuery();
if (query instanceof SQLSelectQueryBlock) {
SQLSelectQueryBlock sQLSelectQueryBlock = (SQLSelectQueryBlock) query;
SQLLimit sQLLimit = sQLSelectQueryBlock.getLimit();
if (sQLLimit == null) {
// 在sql
sql = sql + "limit 200";
}
}
}
}
catch (Exception e) {
e.printStackTrace();
}
System.out.println(sql);
}