---
title: "Common SQL Connector Functions"
slug: "common-sql-connector-functions"
updated: 2022-09-30T19:22:29Z
published: 2022-09-30T19:22:29Z
---

> ## Documentation Index
> Fetch the complete documentation index at: https://support.tulip.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Common SQL Connector Functions

## Common SQL Connector Functions

*This articles describes how to write some commonly used SQL functions in Tulip Connectors.*

Before reading this guide, see our other tutorial for [creating your first SQL connector function in Tulip](https://support.tulip.co/docs/how-to-write-a-sql-connector-function)

Listed below are a few simple and commonly used SQL Connector Functions that you can utilize in your SQL queries:

## SELECT Statement:

Consider a scenario where you would like to view details about a particular Work Order that is stored in your MES/ERP database. The SELECT statement can help us with this task:

```
SELECT * FROM table_in_your_database
```

This will return all rows and columns from your table.

You can return either a single row or multiple rows. If you want to return a single row, add conditions or limits to your query. Tulip inputs are commonly used in this case. In the example below *work_order_number* is a Tulip function input.

```
SELECT * FROM table_in_your_database  
WHERE column_1 = $work_order_number$
```

If you want to return multiple rows, make sure to check the box under "Return Multiple Rows?"

![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Common%20SQL%20Connector%20Functions_156364626.png)

**Returning Data**

If the database column names match the *output* names that you have defined in the connector function, Tulip will automatically associate the query results with the function outputs. Example: Tulip output is *output_1* and database column is also *output_1*

If the column names in your database *differ* from what you would like to use in Tulip you must use an *alias* to make the proper association between the two.

In the example below *column_1* is from the database and *output_1* is the Tulip output.

```
SELECT column_1 as output_1 FROM table_in_your_database  
where  
first_constraint = $input_1$ and  
second_constraint = $input_2$;
```

![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Common%20SQL%20Connector%20Functions_156365302.png)

## INSERT Statement:

Consider a scenario where you would like to insert into your MES/ERP with data from a Tulip App. You would utilize a simple INSERT function to achieve this task. Here is a sample of what this function looks like in SQL:

```
INSERT INTO table_in_your_database  
(username, user_id, product_id)  
VALUES ($username$, $user_id$, $product_id$)
```

**Now let's break down each part of this function:**

Identify the table in your database

```
INSERT INTO table_in_your_database
```

Choose the columns in your database

```
(username, user_id, product_id)
```

Define the values from Tulip

```
VALUES ($username$, $user_id$, $product_id$)  
```

## UPDATE Statement:

Consider a scenario where you would like to update your MES/ERP with data from a Tulip App, using a Work Order as a key. You would utilize the UPDATE function, as shown below:

```
UPDATE table_in_your_database  
SET column_1 = $input_1$,  
    column_2 = $input_2$  
WHERE work_order = $work_order$
```

**Now let's break down each part of this function:**

Identify the table in your database

```
UPDATE table_in_your_database
```

Define the columns to update with Tulip data

```
SET column_1 = $input_1$,  
    column_2 = $input_2$
```

Use the Work Order as a condition

```
WHERE work_order = $work_order$
```

## Further Reading

- [Calling a Connector Function Using Triggers](https://support.tulip.co/docs/how-to-call-a-connector-function-using-triggers)

---

Did you find what you were looking for?

You can also head to [community.tulip.co](https://community.tulip.co/?utm_source=intercom&amp;utm_medium=article-link&amp;utm_campaign=all) to post your question or see if others have faced a similar question!

**Connectors**

**Connectors** enable real-time connectivity between your Tulip solution and a transactional system (e.g. an ERP). The output of a Connector Function can be used in Tulip Apps, Automations, and Functions.

- **HTTP Connectors** utilize HTTP API endpoints.
- **SQL Connectors** can enable connectivity with certain SQL databases.
- **MQTT Connectors** can connect to MQTT brokers for machine monitoring.

![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/connector.gif)

**Connector Function**

**Connector Functions** are individual operations to interact with an HTTP or SQL Datasources. Connector Functions can have inputs and outputs, and can be called from: Triggers, Functions, Automations, and AI Agents.

Once pulled, data can be used throughout your applications.
