# SQL Subquery not working

**URL:** <https://forum.opensearch.org/t/sql-subquery-not-working/7553>\
**Category:** SQL\
**Created:** [November 9, 2021, 10:22pm UTC](https://forum.opensearch.org/t/sql-subquery-not-working/7553 "2021-11-09T22:22:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bbod7](https://avatars.discourse-cdn.com/v4/letter/b/df705f/32.png) [@bbod7](https://forum.opensearch.org/u/bbod7)\
**Post date:** [November 9, 2021, 10:22pm UTC](https://forum.opensearch.org/t/sql-subquery-not-working/7553/1 "2021-11-09T22:22:52Z")

</div>

I tried the SQL subquery per the documentation here:  
[Complex Queries - Open Distro Documentation](https://opendistro.github.io/for-elasticsearch-docs/docs/sql/complex/), Example 1: Table subquery:

```auto
SELECT m1.field1 from 
index_name m1
WHERE m1.field1 IN(
 Select m2.field1 from index_name m2 where m2.id = 100);

```

and I get the error:  
**no response, this query is not runnable.**  
The subquery when run as top-level works fine!  
So is the subquery syntax supported in Opensearch or not?

---

<div class="post-metadata">

**Author:** ![kris](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/kris/32/2208_2.png) [@kris](https://forum.opensearch.org/u/kris)\
**Post date:** [February 7, 2023, 5:17pm UTC](https://forum.opensearch.org/t/sql-subquery-not-working/7553/2 "2023-02-07T17:17:46Z")

</div>


