The member_language table contains the following columns [id, member_id, language_category]
Here is an example table data structure (member_id, language_category)
1-KR
1-EN
1-CN
1-JP
2-EN
2-CN
2-JP
Here's the query result I want
For example, if the list of categories goes into List.of(EN, CN, JP), I need to get the member_id that has all of these categories applied as LIst In the data above, we should get 1 and 2 as the result.
Then List.of(KR, EN, CN, JP) should only return 1. I want this structure, but I'm not sure how to write the query, can anyone help?
final List<Long> containsLanguageMenteeIds = query
.selectDistinct(availableLanguage.member.id)
.from(availableLanguage)
.where(filteringLanguage(condition.language()))
.orderBy(availableLanguage.member.id.desc())
.fetch();
private Predicate filteringLanguage(final SearchMenteeCondition.LanguageCondition language) {
if (language.contains()) {
return availableLanguage.language.category.in(language.values());
// final BooleanBuilder builder = new BooleanBuilder();
// for (final Language.Category category : language.values()) {
// builder.or(availableLanguage.language.category.eq(category));
// }
// return builder;
}
return null;
}
I wrote the above query with QueryDsl, but this Inquery results in member_id even if one of the elements inside is included, which is not the answer I want.