public SelectSQL() { this.tables = new SQLTable(); this.fields = new FieldsSQL(); this.where = new WhereSQL(); this.orderBy = new OrderBySQL(); this.groupBy = new GroupBySQL(); this.limit = new LimitSQL(); }
public override string GetSQLString(ISQL.DBType type) { if (!StringUtil.IsNullOrEmpty(this.sql)) { return(this.sql); } string field = fields.Size() == 0 ? "*" : fields.GetSQLString(type); string sql = string.Empty; if (type == ISQL.DBType.mysql || limit == null || (limit.GetCount() == 0 && limit.GetStart() == 0)) { sql = "select " + field + " from " + tables.GetSQLString(type) + where.GetSQLString(type) + groupBy.GetSQLString(type) + orderBy.GetSQLString(type) + limit.GetSQLString(type); } else { WhereSQL w1 = where.Clone(); w1.AddCondition(new SQLCondition("rownum", (limit.GetStart() + limit.GetCount() + 1).ToString(), "<", true)); WhereSQL w2 = where.Clone(); w2.AddCondition(new SQLCondition("rownum", (limit.GetStart() + 1).ToString(), "<", true)); sql = "SELECT * FROM ( SELECT A.*, ROWNUM RNNNNNN FROM (SELECT " + field + " FROM " + tables.GetSQLString(type) + where.GetSQLString(type) + groupBy.GetSQLString(type) + orderBy.GetSQLString(type) + ") A WHERE ROWNUM <= " + (limit.GetStart() + limit.GetCount()) + " ) WHERE RNNNNNN >= " + (limit.GetStart() + 1); } return(SQLUtils.RemoveMultiBlank(sql.Trim()).Trim()); }
public DeleteSQL() { this.tables = new SQLTable(); this.where = new WhereSQL(); }
public virtual void SetWhere(WhereSQL where) { this.where = where; }
public UpdateSQL() { this.tables = new SQLTable(); this.fieldValues = new FieldValuesSQL(); this.where = new WhereSQL(); }