Key value pairs in dictionary, and how to retrieve them given one?

I’m wondering on how to retrieve the key given the value of a dictionary?

The way to get value given the key is

array[key] - this will output the value, but what if I have the value and am looking to get the key?

 

 

 

 

q)d:abc!1 2 3 q)d[a] 1 q)d?1 a q)d:abcd!1 2 3 1 q)d?1 a

 

be mindful, with this method and duplicate values, only the first key is returned 

This is exactly, what I’ve been looking for, thank you!

you also can use where clause, which return all keys that have duplicates:

q)dic:abcd!1 2 3 1
q)where dic=1
q)ad
q)