我需要从我的数据库中获取具有几个条件的数据:后端将接收到的两个不同字符串的匹配,但每个字符串都可以在表的一行内的 2 个不同列中找到。
下面是我正在尝试的代码,但它仅标识我需要的匹配项之一,如果找到该位置,则该专业未被过滤。
过滤这两种情况的更好方法是什么?
const result = await LawyersRepo.createQueryBuilder("lawyers")
.where("lawyers.city = :city", {
city: location,
})
.orWhere("lawyers.state = :state", {
state: location,
})
.andWhere("lawyers.specialties like :specialties", {
specialties: `${specialty}%`,
})
.orWhere("lawyers.occupation_area like :specialties", {
specialties: `${specialty}%`,
})
.getMany();