# Inner join like query

**URL:** <https://discuss.dgraph.io/t/inner-join-like-query/11345>\
**Category:** GraphQL\
**Tags:** kind:question\
**Created:** [November 7, 2020, 6:44pm UTC](https://discuss.dgraph.io/t/inner-join-like-query/11345 "2020-11-07T18:44:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![the42](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/the42/32/1030_2.png) [@the42](https://discuss.dgraph.io/u/the42)\
**Post date:** [November 7, 2020, 6:44pm UTC](https://discuss.dgraph.io/t/inner-join-like-query/11345/1 "2020-11-07T18:44:49Z")

</div>

Hi,  
Graph databases are no relational databases. Still, my mind take some time to adapt.

Given the schema:

```auto
type A {
  id ID
  b [B]
}

Type B {
  id ID
  somedata String
  c [C]
}

Type C {
  somefilter Boolean
  data String
}

```

How can I get those elements where A is choosen by id and C must match somefilter = true.

I know the GraphQL query would be like

```auto
query {queryA(filter: {id: 0x1}) {
  id
  b {
   id
   somedata
   c (filter: {somefilter: {eq: true}}) {
     id
     somedata
    }
  }
}}

```

but the problem is that elements get returned which satisfy the filter on A but may have no element B or element of type C. So the filters as a whole work like “outer joins”. Sure this can be fine but what if my filters in sum must match. Thus, what is the equivalent of an inner join?

btw. `@cascade` only helps in those cases, where all the requested fields should be set.#

Does GraphQL provide this expressiveness? If not, does DQL?

---

<div class="post-metadata">

**Author:** ![spinelsun](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/spinelsun/32/4596_2.png) [@spinelsun](https://discuss.dgraph.io/u/spinelsun)\
**Post date:** [November 8, 2020, 6:24am UTC](https://discuss.dgraph.io/t/inner-join-like-query/11345/2 "2020-11-08T06:24:34Z")

</div>

Hi,

You should add the `@cascade` directive on b and it should work.  
This directive eliminates result that doesn’t have the fields you want.

```auto
query {getA(id: "0x1") {
  id
  b @cascade{
   id
   somedata
   c (filter: {somefilter: {eq: true}}) {
     id
     somedata
    }
  }
}}

```
