# How to write SQL clause were group of columns is in array of values

**URL:** https://discuss.tryton.org/t/how-to-write-sql-clause-were-group-of-columns-is-in-array-of-values/6345
**Category:** Developer
**Tags:** python-sql
**Created:** [July 14, 2023, 2:43pm UTC](https://discuss.tryton.org/t/how-to-write-sql-clause-were-group-of-columns-is-in-array-of-values/6345 "2023-07-14T14:43:56Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![andres53016](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/andres53016/32/406_2.png) [@andres53016](https://discuss.tryton.org/u/andres53016)
#### Post date: [July 14, 2023, 2:43pm UTC](https://discuss.tryton.org/t/how-to-write-sql-clause-were-group-of-columns-is-in-array-of-values/6345/1 "2023-07-14T14:43:56Z")

</div>

I want create a SQL query like this:  
`select * from table where (table.id,table.state) in (values (80,'stateA'),(13,'stateB'))`  
But I don’t know how to group the columns to call the _in\__ method.

Thanks in advance.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [July 14, 2023, 4:17pm UTC](https://discuss.tryton.org/t/how-to-write-sql-clause-were-group-of-columns-is-in-array-of-values/6345/2 "2023-07-14T16:17:54Z")

</div>

Well Array is not standard SQL so python-sql does not implement them.

---

<div class="post-metadata">

### Author: ![andres53016](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/andres53016/32/406_2.png) [@andres53016](https://discuss.tryton.org/u/andres53016)
#### Post date: [July 14, 2023, 5:07pm UTC](https://discuss.tryton.org/t/how-to-write-sql-clause-were-group-of-columns-is-in-array-of-values/6345/3 "2023-07-14T17:07:57Z")

</div>

Thank you very much for the answer Cedric, I solved it in the following way in case someone else needs it:

```auto
where=(
                ((table.id).in_(list_idsA) & (table.state == 'stateA'))
                | ((table.id).in_(list_idsB) & (table.state == 'stateB'))
                | ((table.id).in_(list_idsC) & (table.state == 'stateC'))
                )))

```
