碰到既有and也有or的情况,容易有坑,建议采用并集查找的方法。
原表:select u from user as u where u.id = 1 and u.name = 'ldd' or u.id = 2 and u.name = 'ddd'
上表有很大的问题,注意细看!!!
修改后的表:select u from user as u where u.id = 1 and u.name = 'ldd'
union
select u from user as u where u.id = 2 and u.name = 'ddd'
建议使用后表查询。