# SupportSQLiteQueryBuilder

Artifact: [androidx.sqlite:sqlite](https://developer.android.com/jetpack/androidx/releases/sqlite) [View Source](https://cs.android.com/search?q=file:androidx/sqlite/db/SupportSQLiteQueryBuilder.android.kt+class:androidx.sqlite.db.SupportSQLiteQueryBuilder) Added in [2.0.0](https://developer.android.com/jetpack/androidx/releases/sqlite#2.0.0)

*** ** * ** ***


```
public final class SupportSQLiteQueryBuilder
```

<br />

*** ** * ** ***

A simple query builder to create SQL SELECT queries.

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder` | `https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder#builder(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html tableName)` Creates a query for the given table name. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder` | `https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder#columns(kotlin.Array)(String[] columns)` Sets the given list of columns as the columns that will be returned. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQuery` | `https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder#create()()` Creates the `https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQuery` that can be passed into `https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteDatabase#query(kotlin.String)`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder` | `https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder#distinct()()` Adds DISTINCT keyword to the query. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder` | `https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder#groupBy(kotlin.String)(https://developer.android.com/reference/java/lang/String.html groupBy)` Adds a GROUP BY statement. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder` | `https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder#having(kotlin.String)(https://developer.android.com/reference/java/lang/String.html having)` Adds a HAVING statement. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder` | `https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder#limit(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html limit)` Adds a LIMIT statement. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder` | `https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder#orderBy(kotlin.String)(https://developer.android.com/reference/java/lang/String.html orderBy)` Adds an ORDER BY statement. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder` | `https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder#selection(kotlin.String,kotlin.Array)(https://developer.android.com/reference/java/lang/String.html selection, Object[] bindArgs)` Sets the arguments for the WHERE clause. |

## Public methods

### builder

Added in [2.3.0](https://developer.android.com/jetpack/androidx/releases/sqlite#2.3.0)

```
public static final @NonNull SupportSQLiteQueryBuilder builder(@NonNull String tableName)
```

Creates a query for the given table name.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html tableName` | The table name(s) to query. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder` | A builder to create a query. |

### columns

Added in [2.0.0](https://developer.android.com/jetpack/androidx/releases/sqlite#2.0.0)

```
public final @NonNull SupportSQLiteQueryBuilder columns(String[] columns)
```

Sets the given list of columns as the columns that will be returned.

| Parameters |
|---|---|
| `String[] columns` | The list of column names that should be returned. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder` | this |

### create

Added in [2.0.0](https://developer.android.com/jetpack/androidx/releases/sqlite#2.0.0)

```
public final @NonNull SupportSQLiteQuery create()
```

Creates the `https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQuery` that can be passed into `https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteDatabase#query(kotlin.String)`.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQuery` | a new query |

### distinct

Added in [2.0.0](https://developer.android.com/jetpack/androidx/releases/sqlite#2.0.0)

```
public final @NonNull SupportSQLiteQueryBuilder distinct()
```

Adds DISTINCT keyword to the query.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder` | this |

### groupBy

Added in [2.0.0](https://developer.android.com/jetpack/androidx/releases/sqlite#2.0.0)

```
public final @NonNull SupportSQLiteQueryBuilder groupBy(String groupBy)
```

Adds a GROUP BY statement.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html groupBy` | The value of the GROUP BY statement. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder` | this |

### having

Added in [2.0.0](https://developer.android.com/jetpack/androidx/releases/sqlite#2.0.0)

```
public final @NonNull SupportSQLiteQueryBuilder having(String having)
```

Adds a HAVING statement. You must also provide `https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder#groupBy(kotlin.String)` for this to work.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html having` | The having clause. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder` | this |

### limit

Added in [2.0.0](https://developer.android.com/jetpack/androidx/releases/sqlite#2.0.0)

```
public final @NonNull SupportSQLiteQueryBuilder limit(@NonNull String limit)
```

Adds a LIMIT statement.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html limit` | The limit value. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder` | this |

### orderBy

Added in [2.0.0](https://developer.android.com/jetpack/androidx/releases/sqlite#2.0.0)

```
public final @NonNull SupportSQLiteQueryBuilder orderBy(String orderBy)
```

Adds an ORDER BY statement.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html orderBy` | The order clause. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder` | this |

### selection

Added in [2.0.0](https://developer.android.com/jetpack/androidx/releases/sqlite#2.0.0)

```
public final @NonNull SupportSQLiteQueryBuilder selection(String selection, Object[] bindArgs)
```

Sets the arguments for the WHERE clause.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html selection` | The list of selection columns |
| `Object[] bindArgs` | The list of bind arguments to match against these columns |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/db/SupportSQLiteQueryBuilder` | this |