Search in sources :

Example 6 with SQLSelectQueryBlock

use of com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock in project druid by alibaba.

the class SQLSelectBuilderImpl method select.

public SQLSelectBuilderImpl select(String... columns) {
    SQLSelectQueryBlock queryBlock = getQueryBlock();
    for (String column : columns) {
        SQLSelectItem selectItem = SQLUtils.toSelectItem(column, dbType);
        queryBlock.addSelectItem(selectItem);
    }
    return this;
}
Also used : SQLSelectItem(com.alibaba.druid.sql.ast.statement.SQLSelectItem) SQLSelectQueryBlock(com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock)

Example 7 with SQLSelectQueryBlock

use of com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock in project druid by alibaba.

the class SQLSelectBuilderImpl method groupBy.

@Override
public SQLSelectBuilderImpl groupBy(String expr) {
    SQLSelectQueryBlock queryBlock = getQueryBlock();
    SQLSelectGroupByClause groupBy = queryBlock.getGroupBy();
    if (groupBy == null) {
        groupBy = createGroupBy();
        queryBlock.setGroupBy(groupBy);
    }
    SQLExpr exprObj = SQLUtils.toSQLExpr(expr, dbType);
    groupBy.addItem(exprObj);
    return this;
}
Also used : SQLSelectGroupByClause(com.alibaba.druid.sql.ast.statement.SQLSelectGroupByClause) SQLSelectQueryBlock(com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock) SQLExpr(com.alibaba.druid.sql.ast.SQLExpr)

Example 8 with SQLSelectQueryBlock

use of com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock in project druid by alibaba.

the class SQLSelectBuilderImpl method from.

@Override
public SQLSelectBuilderImpl from(String table, String alias) {
    SQLSelectQueryBlock queryBlock = getQueryBlock();
    SQLExprTableSource from = new SQLExprTableSource(new SQLIdentifierExpr(table), alias);
    queryBlock.setFrom(from);
    return this;
}
Also used : SQLSelectQueryBlock(com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock) SQLIdentifierExpr(com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr) SQLExprTableSource(com.alibaba.druid.sql.ast.statement.SQLExprTableSource)

Example 9 with SQLSelectQueryBlock

use of com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock in project druid by alibaba.

the class SQLSelectBuilderImpl method having.

@Override
public SQLSelectBuilderImpl having(String expr) {
    SQLSelectQueryBlock queryBlock = getQueryBlock();
    SQLSelectGroupByClause groupBy = queryBlock.getGroupBy();
    if (groupBy == null) {
        groupBy = createGroupBy();
        queryBlock.setGroupBy(groupBy);
    }
    SQLExpr exprObj = SQLUtils.toSQLExpr(expr, dbType);
    groupBy.setHaving(exprObj);
    return this;
}
Also used : SQLSelectGroupByClause(com.alibaba.druid.sql.ast.statement.SQLSelectGroupByClause) SQLSelectQueryBlock(com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock) SQLExpr(com.alibaba.druid.sql.ast.SQLExpr)

Example 10 with SQLSelectQueryBlock

use of com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock in project druid by alibaba.

the class SQLSelectBuilderImpl method selectWithAlias.

@Override
public SQLSelectBuilderImpl selectWithAlias(String column, String alias) {
    SQLSelectQueryBlock queryBlock = getQueryBlock();
    SQLExpr columnExpr = SQLUtils.toSQLExpr(column, dbType);
    SQLSelectItem selectItem = new SQLSelectItem(columnExpr, alias);
    queryBlock.addSelectItem(selectItem);
    return this;
}
Also used : SQLSelectItem(com.alibaba.druid.sql.ast.statement.SQLSelectItem) SQLSelectQueryBlock(com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock) SQLExpr(com.alibaba.druid.sql.ast.SQLExpr)

Aggregations

SQLSelectQueryBlock (com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock)33 SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)13 SQLSelectQuery (com.alibaba.druid.sql.ast.statement.SQLSelectQuery)13 SQLSelectStatement (com.alibaba.druid.sql.ast.statement.SQLSelectStatement)10 SQLSelectItem (com.alibaba.druid.sql.ast.statement.SQLSelectItem)9 SQLBinaryOpExpr (com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr)8 SQLSelect (com.alibaba.druid.sql.ast.statement.SQLSelect)8 SQLIdentifierExpr (com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr)7 SQLStatement (com.alibaba.druid.sql.ast.SQLStatement)6 SQLSubqueryTableSource (com.alibaba.druid.sql.ast.statement.SQLSubqueryTableSource)5 SQLLimit (com.alibaba.druid.sql.ast.SQLLimit)3 SQLOver (com.alibaba.druid.sql.ast.SQLOver)3 SQLAggregateExpr (com.alibaba.druid.sql.ast.expr.SQLAggregateExpr)3 SQLAllColumnExpr (com.alibaba.druid.sql.ast.expr.SQLAllColumnExpr)3 SQLNumberExpr (com.alibaba.druid.sql.ast.expr.SQLNumberExpr)3 SQLPropertyExpr (com.alibaba.druid.sql.ast.expr.SQLPropertyExpr)3 OracleStatementParser (com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser)3 PGSelectQueryBlock (com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGSelectQueryBlock)3 SQLStatementParser (com.alibaba.druid.sql.parser.SQLStatementParser)3 SQLOrderBy (com.alibaba.druid.sql.ast.SQLOrderBy)2