# Query Favorite & Keyword Binding

There are some queries you want to reuse in different contexts or with different objects quite frequently. You can add it to favorite and assign a keyword for reference and call it quickly using that keyword later.

![](/files/-Lru25T4UR0_Fz1vBoZD)

## **New favorite query**

**To add a new favorite query:**

* Right click on the **Favorite** section on the left sidebar.
* Choose **`New`** > **`File...`**
* From the popup editor window, name the query and its binding keyword
* Press **`⌘ + S`** to save the changes and then close the window.

**To add a query to favorite from the Editor or from the History:**

* Select the query from the editor (you can also choose from **History** tab)
* Right-click and choose **`Add to favorite`**
* From the popup editor window, name the query and its binding keyword
* Press **`⌘ + S`** to save the changes and then close the window.

Later, when you want to use a favorite query, type the assigned keyword and TablePlus will insert that query into the editor.

## **Use a favorite query**

**To use a query from Favorite from the Editor,** type the assigned keyword and hit Enter, the query will be inserted.

Or you can find the query in the Favorite and choose:

* **`Run`** to execute the query in a new tab
* **`Copy`** to copy the query to the clipboard, you can also select it and use shortcut key **`⌘ + C`** then paste it to the Query Editor.
* **`Import...`** to use the favorite query via the SQL Import Wizard.
* **`Open in anew tab`** to open Query Editor in a new tab and insert the query into it.
* **`Insert to SQL Editor`** to insert the query into the current Query Editor.

To open a favorite query in a separate SQL Viewer and edit its code, name, and keyword, right click on the query and choose **`Edit/Rename`**. When the edit is done, press **`⌘ + S`** to save it.

{% hint style="info" %}
To avoid auto saving queries while editing it in the Query Editor, go to Preferences (Cmd + ,) and unselect the **`Auto save queries while editing`** option in the General tab.&#x20;

You can also change this via the dropdown menu at the bottom of the left sidebar
{% endhint %}

## **Delete favorite query**

**To delete a query from Favorite**, right click on the query and choose **`Delete`**

## **Show query file location**&#x20;

**To see the location of the SQL file that contains query**, right click on the query and choose **`Show in Finder`**

## Favorite query folder

Favorite queries can be grouped into folders.

**To create a new favorite folder**, you can either:

* Right click on the Favorite section and choose **`New`** > **`Folder...`**
* Or right click on the Favorite section and choose **`New`** > **`Add Folder to Favorites...`**, then select the query folder on your computer to import into Favorite.

**To add a favorite query into a folder**, drag and drop the query to the folder you want.

**To rename a favorite folder**, right click on the folder and choose **`Edit/Rename`**

**To delete a favorite folder**, right click on the folder and choose **`Delete`**

## Customize Favorite

By default, when double click on the favorite query, TablePlus runs the query. You can change this default behaviour using the dropdown menu at the bottom of the left sidebar.&#x20;

If you enable **`Double click to Insert Favorite`**, when you double on a favorite query, TablePlus insert it to the current tab of Query Editor instead.

![](/files/-Ls2kv1-DUDCQ98v3w8c)

You can select/unselect **`Auto save Favorite`** to enable/disable autosave while editing favorite queries


---

# 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://docs.tableplus.com/query-editor/keyword-binding-favorite.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.
