# Checking for role equality in type inference

**URL:** <https://forum.typedb.com/t/checking-for-role-equality-in-type-inference/197>\
**Category:** TypeQL\
**Created:** [7 September 2022 13:58 UTC](https://forum.typedb.com/t/checking-for-role-equality-in-type-inference/197 "2022-09-07T13:58:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![thayne](https://avatars.discourse-cdn.com/v4/letter/t/c4cdca/32.png) [@thayne](https://forum.typedb.com/u/thayne)\
**Post date:** [7 September 2022 13:58 UTC](https://forum.typedb.com/t/checking-for-role-equality-in-type-inference/197/1 "2022-09-07T13:58:47Z")

</div>

I have several two-way relations in my schema. I want to get both roles from all relations where at least one role has a specific type.

Here’s my query:  
`match $relation relates $role1; $relation relates $role2; $ent type my-type; $ent plays $role1; get $role1, $role2;`  
But some results have the same role for $role1 and $role2. I would like to add a clause like: `$role1 != $role2;` or `not {$role1 role $role2;};`. But I get errors. What’s the right syntax for this? Or maybe there’s a better way to do this query?

---

<div class="post-metadata">

**Author:** ![joshua](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.typedb.com/joshua/32/28_2.png) [@joshua](https://forum.typedb.com/u/joshua)\
**Post date:** [7 September 2022 14:45 UTC](https://forum.typedb.com/t/checking-for-role-equality-in-type-inference/197/2 "2022-09-07T14:45:37Z")

</div>

To do concept inequality you can use `not { $role1 is $role2;};`

Hope that helps!

---

<div class="post-metadata">

**Author:** ![thayne](https://avatars.discourse-cdn.com/v4/letter/t/c4cdca/32.png) [@thayne](https://forum.typedb.com/u/thayne)\
**Post date:** [7 September 2022 15:11 UTC](https://forum.typedb.com/t/checking-for-role-equality-in-type-inference/197/3 "2022-09-07T15:11:40Z")

</div>

Thanks! I tried but failed to find this in the documentation ([Match Clause | Vaticle](https://docs.vaticle.com/docs/query/match-clause)). Is it documented somewhere else? There are lots of nice examples there, but doesn’t seem to be comprehensive. Some BNF or similar definition of the syntax would be nice to have in the docs I think.

---

<div class="post-metadata">

**Author:** ![joshua](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.typedb.com/joshua/32/28_2.png) [@joshua](https://forum.typedb.com/u/joshua)\
**Post date:** [7 September 2022 15:18 UTC](https://forum.typedb.com/t/checking-for-role-equality-in-type-inference/197/4 "2022-09-07T15:18:11Z")

</div>

Wow! You’re right we don’t have `is` in the docs! I will add it now.

Linking the grammar is a good idea as well, here it is for now: [typeql/TypeQL.g4 at master · vaticle/typeql · GitHub](https://github.com/vaticle/typeql/blob/master/grammar/TypeQL.g4)

---

<div class="post-metadata">

**Author:** ![joshua](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.typedb.com/joshua/32/28_2.png) [@joshua](https://forum.typedb.com/u/joshua)\
**Post date:** [7 September 2022 16:41 UTC](https://forum.typedb.com/t/checking-for-role-equality-in-type-inference/197/5 "2022-09-07T16:41:58Z")

</div>

All updated - [Match Clause | Vaticle](https://docs.vaticle.com/docs/query/match-clause#concept-equality)
