# KEEP

The KEEP command allows you to specify which columns are returned and the order in which they appear. When a field name matches multiple expressions, precedence rules determine which expression is used: complete field names have the highest priority, followed by partial wildcard expressions, and finally the wildcard-only expression. If two expressions have the same precedence, the rightmost one takes priority.

## Syntax

`KEEP columns`

### Parameters

#### columns

A comma-separated list of columns to keep. Wildcards are supported. If a column matches multiple expressions, precedence rules are applied to determine which expression is used.

## Examples

Selects and orders the columns emp_no, first_name, last_name, and height.

```esql
FROM employees
| KEEP emp_no, first_name, last_name, height
```

Returns all columns whose names start with "h".

```esql
FROM employees
| KEEP h*
```

Returns columns starting with "h" followed by all remaining columns.

```esql
FROM employees
| KEEP h*, *
```

Returns first_name and last_name, with first_name taking precedence over the wildcard.

```esql
FROM employees
| KEEP first_name, last_name, first_name*
```

Returns columns matching first_name* and first_na*, with the rightmost expression taking precedence.

```esql
FROM employees
| KEEP first_name*, last_name, first_na*
```

Returns all columns, with first_name appearing last due to its position in the argument list.

```esql
FROM employees
| KEEP *, first_name
```