# Searching, Filtering, and Sorting Data in a Database

Searching and filtering are fundamental features that empower users to efficiently navigate databases and extract valuable insights. These functionalities play a crucial role in enhancing productivity, supporting decision-making processes, and maintaining the integrity of stored data. Additionally, users have the flexibility to arrange data records in either ascending or descending order.&#x20;

In this article, we'll guide you on how to search, filter, and sort data in a database.

## <mark style="color:blue;">Searching for Data</mark>

There are two approaches to locating data in a database:

1. [Searching for Data by Entering a Search Term](#id-1.-searching-for-data-by-entering-a-search-term)
2. [Searching for Data by Entering a MongoDB Query](#id-2.-searching-for-data-by-entering-a-mongodb-query)

### <mark style="color:blue;">1. Searching for Data by Entering a Search Term</mark>

To search for data records by entering a search term:

1. On the app **homepage**, go to the **My Work** tab on the left sidebar.
2. All the folders you have created, as well as those created by others, will be listed.
3. If you cannot locate the folder in the list, type in the folder name under **Search Folders.**
4. Click on the folder you wish to open.
5. Head to the **Databases** tab.
6. Search and click on the required **database**.
7. A spreadsheet view of your database will be opened in a new window.
8. Type in the search term in the **Search** box to search and filter rows.

### <mark style="color:blue;">2. Searching for Data by Entering a MongoDB Query</mark>

For those with advanced expertise, you have the option to input a[ MongoDB query](https://www.mongodb.com/docs/manual/tutorial/query-documents/) directly into the search box or type it in the editor window.

1. On the app **homepage**, go to the **My Work** tab on the left sidebar.
2. All the folders you have created, as well as those created by others, will be listed.
3. If you cannot locate the folder in the list, type in the folder name under **Search Folders.**
4. Click on the folder you wish to open.
5. Head to the **Databases** tab.
6. Search and click on the required **database**.
7. A spreadsheet view of your database will be opened in a new window.
8. Type in the MongoDB query in the search box.
9. Instead, you can click the expand icon to enter the query in a editor window.

<figure><img src="https://333252015-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTG5DCdGHEfzVksM49xh8%2Fuploads%2F9P7Omj0lfWjirpk2sHDU%2FLC_Searching%20and%20Filtering%20Information%20in%20a%20Database_S2.png?alt=media&#x26;token=44fb3413-8cab-4d92-adab-e3a2b728c998" alt="" width="344"><figcaption><p>Searching data records by Entering a MongoDB Query</p></figcaption></figure>

## <mark style="color:blue;">Filtering Data</mark>

Filtering data in a database involves narrowing down the dataset to only include records that meet certain requirements.

There are several ways to filter data records in your database view:

1. [Filtering Records by Selecting Column Values](#id-1.-filtering-records-by-selecting-column-values)
2. [Filtering Records by Selecting Columns](#id-2.-filtering-records-by-selecting-columns)

### <mark style="color:blue;">1. Filtering Records by Selecting Column Values</mark>

To filter data records by selecting specific column values:

1. On the app **homepage**, go to the **My Work** tab on the left sidebar.
2. All the folders you have created, as well as those created by others, will be listed.
3. If you cannot locate the folder in the list, type in the folder name under **Search Folders.**
4. Click on the folder you wish to open.
5. Head to the **Databases** tab.
6. Search and click on the required database.
7. A spreadsheet view of your database will be opened in a new window.
8. On the spreadsheet, click **Filters & Options.**
9. Under the **Filters** menu, click on the required database column to expand it.
10. Within each column, you'll find a list of column values.
11. Choose the specific column values within the column to apply the filtering and display the corresponding data in your spreadsheet view.

### <mark style="color:blue;">2. Filtering Records by Selecting Columns</mark>

To filter data records by selecting specific columns:

1. On the app **homepage**, go to the **My Work** tab on the left sidebar.
2. All the folders you have created, as well as those created by others, will be listed.
3. If you cannot locate the folder in the list, type in the folder name under **Search Folders.**
4. Click on the folder you wish to open.
5. Head to the **Databases** tab.
6. Search and click on the required **database**.
7. A spreadsheet view of your database will be opened in a new window.
8. On the spreadsheet, click **Filters & Options.**
9. Click **Toggle Columns** menu.
10. Select the Columns you are interested in.
11. Only the data related to the selected columns will be displayed in the spreadsheet view. In other words, rest of the columns will be hidden from the view.

## <mark style="color:blue;">Sorting Data</mark>

To sort data in ascending or descending order:

1. On the app **homepage**, go to the **My Work** tab on the left sidebar.
2. All the folders you have created, as well as those created by others, will be listed.
3. If you cannot locate the folder in the list, type in the folder name under **Search Folders.**
4. Click on the folder you wish to open.
5. Head to the **Databases** tab.
6. Search and click on the required **database**.
7. A spreadsheet view of your database will be opened in a new window.
8. On the view, click **Filters & Options.**
9. Choose the **column** from the list that you'd like to use for sorting the data.
10. Select the sorting order as either ASC (ascending) or DESC (descending).
11. Data will be sorted and displayed based on the selected column.

Here is a short video that shows how to search, filter, and sort data in a database to help you understand better.

{% embed url="<https://drive.google.com/file/d/19OcgLFYvhKoLwgVYLOT1wipqa3G8xReG/view?usp=drive_link>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.iviva.com/lucy/my-work-folders/databases/searching-filtering-and-sorting-data-in-a-database.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
