How to query entries by field values I have some entries with a multi-select field called "gallery". We can choose many images to this field.

I have a given image, how can I query entries whose "gallery" contains this given image? Thx!

I have tried like this with no success:

Entry::find()
  -&gt;section($section)
  -&gt;galleryImages('contains' . $image-&gt;id)
  -&gt;all();
There is a related to parameter you can use



Entry::find()
  -&gt;section($section)
  -&gt;relatedTo(['targetElement' =&gt; $image-&gt;id, 'field' =&gt; 'galleryImages')
  -&gt;all();