# (no subject)

**URL:** <https://discuss.elastic.co/t/no-subject/7174>\
**Category:** Elasticsearch\
**Created:** [March 30, 2012, 7:44am UTC](https://discuss.elastic.co/t/no-subject/7174 "2012-03-30T07:44:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhishek\_Jajoria](https://avatars.discourse-cdn.com/v4/letter/a/b5e925/32.png) [@Abhishek\_Jajoria](https://discuss.elastic.co/u/Abhishek_Jajoria)\
**Post date:** [March 30, 2012, 7:44am UTC](https://discuss.elastic.co/t/no-subject/7174/1 "2012-03-30T07:44:51Z")

</div>

how to query in elasticsearch the following sql query

select \* from tbl1.name where tbl1.id = tbl2.id;

I have index the two table with the same field as the columns in the table  
and I do not want to change the mapping

Can two types be connected with a common field and get the query out of it  
.  
That field which is primary field(type) on one index and foreign(type) key  
in another.Like we do in sql.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 30, 2012, 8:12am UTC](https://discuss.elastic.co/t/no-subject/7174/2 "2012-03-30T08:12:53Z")

</div>

Heya,

IMHO, thinking YesSQL in a NoSQL world is not the best way to solve  
problems if your aim is to have the fastest response time when you search  
for documents.  
I mean that in term of search point of view, you should perhaps design your  
documents regarding the way you want to query them.  
So, in your example, why not sending to ES a document containing tbl1  
content AND tbl2 content ?

What is exactly your use case ?

HTH

Le 30 mars 2012 à 09:44, jajoria abhishek [jajoria.abhishek@gmail.com](mailto:jajoria.abhishek@gmail.com) a  
écrit :

> how to query in elasticsearch the following sql query
> 
> select \* from tbl1.name [http://tbl1.name](http://tbl1.name) where tbl1.id [http://tbl1.id](http://tbl1.id)  
> = tbl2.id [http://tbl2.id](http://tbl2.id) ;
> 
> I have index the two table with the same field as the columns in the table  
> and I do not want to change the mapping
> 
> Can two types be connected with a common field and get the query out of it  
> .  
> That field which is primary field(type) on one index and foreign(type) key  
> in another.Like we do in sql.

--  
David Pilato  
[http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
Twitter : @dadoonet

---

<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 6, 2017, 3:34am UTC](https://discuss.elastic.co/t/no-subject/7174/3 "2017-07-06T03:34:08Z")

</div>

Closed on July 6, 2017, 3:34am UTC


