# In-Line SQL Statements

## Original V16 Statement

{% code overflow="wrap" %}
```csharp
var filterOriginal = rows.Select(x => $"(container='{x["container"]}' AND docid={x["docid"]})");

var tableOriginal = await Sql.SelectTableAsync($@"SELECT hybrid 
FROM dms_link 
WHERE hybrid LIKE 'pers^%' 
AND ({filterOriginal.StrCat(" or ")})");
```
{% endcode %}

***

## V17 **Conversion**

#### PostgreSQL allows comparision of touples/pairs

{% code overflow="wrap" %}
```csharp
// using IN
var filterComposed = rows.StrCat(",", x => $"('{x["container"].ToStringNN()}', {x["docid"].ToInt()})");

var tableComposed = await Sql.SelectTableAsync($@"SELECT hybrid 
FROM dms_link 
WHERE hybrid LIKE 'pers^%' 
AND (container, docid) IN ({filterComposed})");
```
{% endcode %}

#### Simplifying to a single entry

{% code overflow="wrap" fullWidth="false" %}
```csharp
var filter = "container = :container AND docid= :docid"; 

var table = await Sql.SelectTableAsync($@"SELECT hybrid
FROM dms_link
WHERE hybrid LIKE 'pers^%' 
AND ({filter})", new { container = "2009", docid = 1 });
```
{% endcode %}

#### Wrong!

{% code overflow="wrap" fullWidth="false" %}
```csharp
var filter = rows.Select(x => $"(container = '{x["container"]}' AND docid ={x["docid"]})");

var table = await Sql.SelectTableAsync(@"SELECT hybrid
FROM dms_link
WHERE hybrid LIKE 'pers^%' 
AND (:filter) ", new { filter = filter.StrCat(" or ") });
```
{% endcode %}

{% hint style="danger" %}
Using an SQL statement as an argument within another SQL statement is incorrect and will cause errors.
{% endhint %}
