Table selectClause() {
        ArrayList<Condition> conditions = new ArrayList<Condition>();
        ArrayList<String> columnNames = new ArrayList<String>();
        Table table2 = new Table(new String[]{});
        Table result;

        _input.next("select");
        String column = columnName();
        columnNames.add(column);
        while (_input.nextIf(",")) {
            columnNames.add(columnName());
        }
        _input.next("from");
        Table table = tableName();
        if (_input.nextIf(",")) {
            table2 = tableName();
            if (_input.nextIf("where")) {
                conditions.add(condition(table, table2));
                while (_input.nextIf("and")) {
                    conditions.add(condition(table, table2));
                }
            }
        } else {
            if (_input.nextIf("where")) {
                conditions.add(condition(table));
                while (_input.nextIf("and")) {
                    conditions.add(condition(table));
                }
            }
        }
        _input.next(";");
        if (table2.columns() == 0) {
            result = table.select(columnNames, conditions);
        } else {
            result = table.select(table2, columnNames, conditions);
        }
        return result;
    }