碰到既有and也有or的情況,容易有坑,建議采用并集查找的方法。
原表:select u from user as u where u.id = 1 and u.name = 'ldd' or u.id = 2 and u.name = 'ddd'
上表有很大的問題,注意細(xì)看!??!
修改后的表: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'
建議使用后表查詢。
2018-09-04
既有and又有or的話建議用小括號括起來 自己確定好優(yōu)先級
2018-02-06
碰到既有and也有or的情況,容易有坑,建議采用并集查找的方法。
原表:select u from user as u where u.id = 1 and u.name = 'ldd' or u.id = 2 and u.name = 'ddd'
上表有很大的問題,注意細(xì)看!??!
修改后的表: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'
建議使用后表查詢。
2017-12-27
沒看懂你想表達(dá)的意思