{ (selectStatement) [AS] label | tableName [AS] label}
508146
private void selectExpressions(ParserString raw, Select select) throws SQLParserException {
	Expression exp = null;
	do {
	    raw.removeSpace();

	    exp = expression(raw);
	    if (exp == null) throw new SQLParserException("missing expression in select part of query");
	    raw.removeSpace();
	    if (raw.forwardIfCurrent("as ")) {
		String alias = identifier(raw, new RefBooleanImpl(false));
		if (alias == null) throw new SQLParserException("missing alias in select part");
		exp.setAlias(alias);
	    }
	    else {
		int start = raw.getPos();
		RefBoolean hb = new RefBooleanImpl(false);
		String alias = identifier(raw, hb);
		if (!hb.toBooleanValue() && "from".equalsIgnoreCase(alias)) raw.setPos(start);
		else if (alias != null) exp.setAlias(alias);
	    }
	    select.addSelectExpression(exp);
	    raw.removeSpace();
	}
	while (raw.forwardIfCurrent(','));

    }
816688
public static function getLabelsFromTable(string $tableName, string $idColumnName, string $labelColumnName): array
  {
    $query = "
select `%s`  id
,      `%s`  label
from   `%s`
where   nullif(`%s`,'') is not null";

    $query = sprintf($query, $idColumnName, $labelColumnName, $tableName, $labelColumnName);

    return self::executeRows($query);
  }
814946
def label(self):
        """""""
        for c in self.table.columns:
            if c.parent == self.name and 'label' in c.valuetype:
                return PartitionColumn(c, self._partition)
143452
function selectColumnSql (model, column, spec, alias, as) {
    // if alias is not registered then this should be a table name
    if (!this.aliases[alias]) {
        // create alias from table anme
        alias = this.getAlias(alias)
    }
    // base sql is alias.`column`
    var sql = alias+'.'+this.quoteName(column)
    // if column type is id then select HEX(alias.`column`) AS `column`
    if (spec.type === 'id' && model.binaryIds) {
        sql = 'LOWER(HEX('+sql+')) as '+this.quoteName(typeof as === 'string' ? as : column)
    }
    // if column type is data and compression then select
    // BASE_64(alias.`column`) AS `column`
    else if (spec.type === 'data' && model.compression) {
        sql = 'TO_BASE64('+sql+') as '+this.quoteName(typeof as === 'string' ? as : column)
    }
    // return column sql
    return sql
}
1307601
def quote_table_name(name)
      name.to_s.split('.').map{ |n| n.split('@').map{ |m| quote_column_name(m) }.join('@') }.join('.')
    end
1006005
public SelectStatement getPreparedSelectStatement(Query query, ClassDescriptor cld)
    {
        SelectStatement sql = new SqlSelectStatement(m_platform, cld, query, logger);
        if (logger.isDebugEnabled())
        {
            logger.debug("SQL:" + sql.getStatement());
        }
        return sql;
    }
600086
public String getSelectMNStatement(String table, String[] selectColumns, String[] columns)
    {
        SqlStatement sql;
        String result;

        sql = new SqlSelectMNStatement(table, selectColumns, columns, logger);
        result = sql.getStatement();

        if (logger.isDebugEnabled())
        {
            logger.debug("SQL:" + result);
        }
        return result;
    }
125625
def label(self):
        """""""

        if self.valuetype_class.is_label():
            return self

        for c in self.table.columns:
            if c.parent == self.name and  c.valuetype_class.is_label():
                return c

        return None
1141297
public void parse(final SelectStatement selectStatement) {
        if (!lexerEngine.skipIfEqual(MySQLKeyword.LIMIT)) {
            return;
        }
        int valueIndex = -1;
        int valueBeginPosition = lexerEngine.getCurrentToken().getEndPosition();
        int value;
        boolean isParameterForValue = false;
        if (lexerEngine.equalAny(Literals.INT)) {
            value = Integer.parseInt(lexerEngine.getCurrentToken().getLiterals());
            valueBeginPosition = valueBeginPosition - (value + "").length();
        } else if (lexerEngine.equalAny(Symbol.QUESTION)) {
            valueIndex = selectStatement.getParametersIndex();
            value = -1;
            valueBeginPosition--;
            isParameterForValue = true;
        } else {
            throw new SQLParsingException(lexerEngine);
        }
        lexerEngine.nextToken();
        if (lexerEngine.skipIfEqual(Symbol.COMMA)) {
            selectStatement.setLimit(getLimitWithComma(valueIndex, valueBeginPosition, value, isParameterForValue, selectStatement));
            return;
        }
        if (lexerEngine.skipIfEqual(MySQLKeyword.OFFSET)) {
            selectStatement.setLimit(getLimitWithOffset(valueIndex, valueBeginPosition, value, isParameterForValue, selectStatement));
            return;
        }
        if (isParameterForValue) {
            selectStatement.setParametersIndex(selectStatement.getParametersIndex() + 1);
        } else {
            selectStatement.addSQLToken(new RowCountToken(valueBeginPosition, value));
        }
        Limit limit = new Limit();
        limit.setRowCount(new LimitValue(value, valueIndex, false));
        selectStatement.setLimit(limit);
    }
411425
public void setTableNames(java.util.Collection<String> tableNames) {
        if (tableNames == null) {
            this.tableNames = null;
            return;
        }

        java.util.List<String> tableNamesCopy = new java.util.ArrayList<String>(tableNames.size());
        tableNamesCopy.addAll(tableNames);
        this.tableNames = tableNamesCopy;
    }
1061901
function dsStatement(statement) {
  switch(statement.constructor) {
    case Statements.Blank:
    case Statements.Conditional:
    case Statements.DialogueSegment:
    case Statements.Evaluate:
    case Statements.Function:
    case Statements.Link:
    case Statements.Option:
    case Statements.OptionGroup:
    case Statements.Shortcut:
    case Statements.ShortcutGroup:
      return false;
    case Statements.Command:
    case Statements.LineGroup:
    case Statements.Text:
    case Statements.Hashtag:
      return true;
    default: 
      console.warn(`Unrecognized statement type: ${statement.constructor.name}`);
      return false;
  }
}
998179
def selectis(table, field, value, complement=False):
    """"""

    return selectop(table, field, value, operator.is_, complement=complement)
923623
function isLabeledBy(node, labelName) {
        for (var owner = node.parent; owner.kind === 214 /* LabeledStatement */; owner = owner.parent) {
            if (owner.label.text === labelName) {
                return true;
            }
        }
        return false;
    }
812704
public void init(String tableName, ResultSet columnMetaRs) throws SQLException {
		this.tableName = tableName;

		this.name = columnMetaRs.getString("COLUMN_NAME");
		this.type = columnMetaRs.getInt("DATA_TYPE");
		this.size = columnMetaRs.getInt("COLUMN_SIZE");
		this.isNullable = columnMetaRs.getBoolean("NULLABLE");
		this.comment = columnMetaRs.getString("REMARKS");
	}
881352
function BaseStatement(
    statementOptions, context, services, connectionConfig)
{
  // call super
  EventEmitter.call(this);

  // validate input
  Errors.assertInternal(Util.isObject(statementOptions));
  Errors.assertInternal(Util.isObject(context));

  context.services         = services;
  context.connectionConfig = connectionConfig;
  context.isFetchingResult = true;

  // TODO: add the parameters map to the statement context

  var statement = this;

  /**
   * Returns this statement's SQL text.
   *
   * @returns {String}
   */
  this.getSqlText = function()
  {
    return context.sqlText;
  };

  /**
   * Returns the current status of this statement.
   *
   * @returns {String}
   */
  this.getStatus = function()
  {
    return context.isFetchingResult ? states.FETCHING : states.COMPLETE;
  };

  /**
   * Returns the columns produced by this statement.
   *
   * @returns {Object[]}
   */
  this.getColumns = function()
  {
    return context.result ? context.result.getColumns() : undefined;
  };

  /**
   * Given a column identifier, returns the corresponding column. The column
   * identifier can be either the column name (String) or the column index
   * (Number). If a column is specified and there is more than one column with
   * that name, the first column with the specified name will be returned.
   *
   * @param {String | Number} columnIdentifier
   *
   * @returns {Object}
   */
  this.getColumn = function(columnIdentifier)
  {
    return context.result ? context.result.getColumn(columnIdentifier) :
        undefined;
  };

  /**
   * Returns the number of rows returned by this statement.
   *
   * @returns {Number}
   */
  this.getNumRows = function()
  {
    return context.result ? context.result.getReturnedRows() : undefined;
  };

  /**
   * Returns the number of rows updated by this statement.
   *
   * @returns {Number}
   */
  this.getNumUpdatedRows = function()
  {
    return context.result ? context.result.getNumUpdatedRows() : undefined;
  };

  /**
   * Returns an object that contains information about the values of the
   * current warehouse, current database, etc., when this statement finished
   * executing.
   *
   * @returns {Object}
   */
  this.getSessionState = function()
  {
    return context.result ? context.result.getSessionState() : undefined;
  };

  /**
   * Returns the request id that was used when the statement was issued.
   *
   * @returns {String}
   */
  this.getRequestId = function()
  {
    return context.requestId;
  };

  /**
   * Returns the statement id generated by the server for this statement.
   * If the statement is still executing and we don't know the statement id
   * yet, this method will return undefined.
   *
   * @returns {String}
   */
  this.getStatementId = function()
  {
    return context.statementId;
  };

  /**
   * Cancels this statement if possible.
   *
   * @param {Function} [callback]
   */
  this.cancel = function(callback)
  {
    sendCancelStatement(context, statement, callback);
  };

  /**
   * Issues a request to get the statement result again.
   *
   * @param {Function} callback
   */
  context.refresh = function(callback)
  {
    // pick the appropriate function to get the result based on whether we
    // have the statement id or request id (we should have at least one)
    var sendRequestFn = context.statementId ?
        sendRequestPostExec : sendRequestPreExec;

    // the current result error might be transient,
    // so issue a request to get the result again
    sendRequestFn(context, function(err, body)
    {
      // refresh the result
      context.onStatementRequestComp(err, body);

      // if a callback was specified, invoke it
      if (Util.isFunction(callback))
      {
        callback(context);
      }
    });
  };

  /**
   * Called when the statement request is complete.
   *
   * @param err
   * @param body
   */
  context.onStatementRequestComp = function(err, body)
  {
    // if we already have a result or a result error, we invoked the complete
    // callback once, so don't invoke it again
    var suppressComplete = context.result || context.resultError;

    // clear the previous result error
    context.resultError = null;

    // if there was no error, call the success function
    if (!err)
    {
      context.onStatementRequestSucc(body);
    }
    else
    {
      // save the error
      context.resultError = err;

      // if we don't have a statement id and we got a response from GS, extract
      // the statement id from the data
      if (!context.statementId &&
          Errors.isOperationFailedError(err) && err.data)
      {
        context.statementId = err.data.queryId;
      }
    }

    // we're no longer fetching the result
    context.isFetchingResult = false;

    if (!suppressComplete)
    {
      // emit a complete event
      context.emit('statement-complete', Errors.externalize(err), statement);

      // if a complete function was specified, invoke it
      if (Util.exists(context.complete))
      {
        invokeStatementComplete(statement, context);
      }
    }
    else
    {
      Logger.getInstance().debug('refreshed result of statement with %s',
          context.requestId ?
              Util.format('request id = %s', context.requestId) :
              Util.format('statement id = %s', context.statementId));
    }
  };

  /**
   * Called when the statement request is successful. Subclasses must provide
   * their own implementation.
   *
   * @param {Object} body
   */
  context.onStatementRequestSucc = function(body){};
}
833618
@Override
	public String onColumnFullyQualifiedName(String tableName, String columnName) {
		if (onlyBindParameter)
			return null;

		return JQLReplacerListenerImpl.resolveFullyQualifiedColumnName(currentSchema, currentMethod, tableName, columnName);
	}
829703
public void setStatementLabel(String label) {
        if (statementLabels == null) statementLabels = new LinkedList<String>();
        statementLabels.add(label);
    }