// if (condition != null && condition.size() != 0) {
// conditionStatement = condition.getConditionStatement();
// conditionStatementSize = conditionStatement.size();
// }
StringBuffered sqlStr = new StringBuffered(17)
.append("SELECT ");
ObjectBuffered values = null;//new ObjectBuffered();
/* 生成DISTINCT串 */
if (distinct) {
sqlStr.append(" DISTINCT ");
}
/* 生成返回列的串 */
if (columns != null && columns.length != 0) {
SQL columnSQL = constructSelectedColumn(columns);
sqlStr.append(columnSQL.getSQLStatement());
values = columnSQL.getValueBuffered();
}else{
sqlStr.append("*");
}
/* 生成FROM子串, 如果tableName为空,将不构建FROM子句 */
if (tableName != null && tableName.length() != 0) {
sqlStr.append(" FROM ").append(tableName);
}
/* 生成查询条件串 */
if (condition != null && condition.size() != 0) {
sqlStr.append(" WHERE ").append(condition.getConditionStatement());
if(values==null){
values = condition.getValueBuffered();
}else{
values.append(condition.getValueBuffered());
}
}
/* 生成GROUP BY串 */
if (groupby != null && groupby.length() != 0) {
sqlStr.append(" GROUP BY ").append(groupby);
}
/* 生成ORDER BY串 */
if (orderby != null && orderby.length() != 0) {
sqlStr.append(" ORDER BY ").append(orderby);
}
/* 生成limit串 */
if (rowLen != -1) {
sqlStr.append(" LIMIT ").append(startIndex).append(",").append(rowLen);
}
return new SQL(SQL.SELECT, sqlStr, values, startIndex, rowLen);
}