# SELECT within SELECT query on elasticsearch

**URL:** <https://discuss.elastic.co/t/select-within-select-query-on-elasticsearch/37041>\
**Category:** Elasticsearch\
**Created:** [December 12, 2015, 6:46pm UTC](https://discuss.elastic.co/t/select-within-select-query-on-elasticsearch/37041 "2015-12-12T18:46:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Julia\_Murinova](https://avatars.discourse-cdn.com/v4/letter/j/a88e4f/32.png) [@Julia\_Murinova](https://discuss.elastic.co/u/Julia_Murinova)\
**Post date:** [December 12, 2015, 6:46pm UTC](https://discuss.elastic.co/t/select-within-select-query-on-elasticsearch/37041/1 "2015-12-12T18:46:44Z")

</div>

Hello,  
I am new to using ELK stack for application log management. Is there a way to filter multiple records with specified property (session) according to specified field value not present in all but then list all records with queried sessions in kibana/elasticsearch?

In SQL that would be using nested SELECT:  
SELECT \* from table WHERE sessionID IN (SELECT sessionID from table WHERE customerID='56')

Example records:  
log\_date [152-125-365] message\_type module\_name - New connection - customerID = 56  
log\_date [152-125-365] message\_type module\_name - Connection info  
log\_date [586-526-985] message\_type module\_name - New connection - customerID = 12  
...  
log\_date [785-125-596] message\_type module\_name - New connection - customerID = 56

Desired output: all session messages with specified customerid:  
log\_date [152-125-365] message\_type module\_name - New connection - customerID = 56  
log\_date [152-125-365] message\_type module\_name - Connection info  
log\_date [785-125-596] message\_type module\_name - New connection - customerID = 56

Thanks

---

<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:** [July 5, 2017, 11:31pm UTC](https://discuss.elastic.co/t/select-within-select-query-on-elasticsearch/37041/2 "2017-07-05T23:31:07Z")

</div>


