# When using SQL, the IN statement does not work in the SELECT section of a query

**URL:** <https://discuss.elastic.co/t/when-using-sql-the-in-statement-does-not-work-in-the-select-section-of-a-query/247118>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-sql\
**Created:** [September 1, 2020, 3:23pm UTC](https://discuss.elastic.co/t/when-using-sql-the-in-statement-does-not-work-in-the-select-section-of-a-query/247118 "2020-09-01T15:23:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![meadows.120](https://avatars.discourse-cdn.com/v4/letter/m/46a35a/32.png) [@meadows.120](https://discuss.elastic.co/u/meadows.120)\
**Post date:** [September 1, 2020, 3:23pm UTC](https://discuss.elastic.co/t/when-using-sql-the-in-statement-does-not-work-in-the-select-section-of-a-query/247118/1 "2020-09-01T15:23:31Z")

</div>

ES Version: 7.8

I’m trying to run the following in SQL Workbench, and one query works, but the other one does not…any thoughts?

Successful:

```sql
SELECT
  *
FROM
  my_index
WHERE
  a.b IN ('115')

```

Failure:

```sql
SELECT
  a.b IN ('115') AS 'FOO'
FROM
  my_index

```

---

<div class="post-metadata">

**Author:** ![AClerk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aclerk/32/55297_2.png) [@AClerk](https://discuss.elastic.co/u/AClerk)\
**Post date:** [September 2, 2020, 1:43am UTC](https://discuss.elastic.co/t/when-using-sql-the-in-statement-does-not-work-in-the-select-section-of-a-query/247118/2 "2020-09-02T01:43:00Z")

</div>

What is that syntax?  
What are you trying to achieve?

---

<div class="post-metadata">

**Author:** ![bogdan.pintea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bogdan.pintea/32/45740_2.png) [@bogdan.pintea](https://discuss.elastic.co/u/bogdan.pintea)\
**Post date:** [September 10, 2020, 2:47pm UTC](https://discuss.elastic.co/t/when-using-sql-the-in-statement-does-not-work-in-the-select-section-of-a-query/247118/3 "2020-09-10T14:47:09Z")

</div>

> [@meadows.120](#):
>
> Failure:
> 
> ```auto
> SELECT
> a.b IN ('115') AS 'FOO'
> FROM
> my_index
> 
> ```

This simply is an invalid syntax. See Elastic's [supported syntax](https://www.elastic.co/guide/en/elasticsearch/reference/7.8/sql-syntax-select.html) or any other SQL tutorials.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 8, 2020, 2:47pm UTC](https://discuss.elastic.co/t/when-using-sql-the-in-statement-does-not-work-in-the-select-section-of-a-query/247118/4 "2020-10-08T14:47:14Z")

</div>

Closed on October 8, 2020, 2:47pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
