jParepository查询选择所有包含标签数组的元素
我有一个名为“挑战”的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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论