jParepository查询选择所有包含标签数组的元素

发布于 2025-02-11 17:07:48 字数 464 浏览 0 评论 0原文

我有一个名为“挑战”的Postgres DB表,其中包含一个“标签”文本列,因为挑战的每个标签都存储为“ tag1,tag2,tag3 ...”。

因此,我需要提出一个请求,该请求可以检查挑战是否包含提供的数组中的所有标签,但我不知道该如何制作。

我的存储库方法:

@Query(?)
Page<Challenge> findByTags(String[] tags, Pageable pageable);

到目前为止,我所做的是一个查询,可与一个标签一起使用,但不能与数组一起使用:

SELECT * FROM challenge WHERE tags LIKE '%' || :tag || '%';

I have a postgres db table named "challenge" which contains a 'tags' text column in that each tags of the challenge is stored as "tag1,tag2,tag3...".

So I need to make a request that can check if a challenge contains all tags in the provided array but I don't know how to make this.

My repository method:

@Query(?)
Page<Challenge> findByTags(String[] tags, Pageable pageable);

What i've done so far it's a query which works with one tag but not with an array:

SELECT * FROM challenge WHERE tags LIKE '%' || :tag || '%';

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文