select
*
from
sd_mind_press smp
where
(smp.name = ? and smp.degree = ?)
or (smp.name = ? and smp.degree = ?)
or (smp.name = ? and smp.degree = ?)
or (smp.name = ? and smp.degree = ?)
这样查询的效率更高,一次性查询出结果。
for循环的话,每次都需要建立数据库连接,很影响性能。
所以,能在sql中一次完成的,就不要通过代码方式完成。
尽量减少数据库的连接次数,这样查询性能更高,如果是频繁使用这2个字段作为查询条件,最好为这2个字段创建索引。
不知道你这个问题是否已经解决, 如果还没有解决的话:1、在Mapper 文件中我试了下暂时还没想出来,后面研究。
2、根据老师的写法如下: