逻辑运算:通过逻辑运算符,将逻辑表达式按照逻辑运算规则,形成一个新的逻辑表达式。
逻辑运算符:and(逻辑与)——如果逻辑表达式运算结果都为true则为true否则就为false、or(逻辑或)——如果逻辑表达式运算结果都为false则为false否则就为true、not(逻辑非)——对布尔运算结果取反。
案例:查询商品价格在100到5000元之间,并且类型为电脑类型
案例2:查询商品价格在100到5000之间或者是电脑类型
逻辑运算
and (与)、 or(或) 、 not(非)
逻辑运算1
逻辑运算符 1.and(逻辑与)、or(逻辑或) 2.not(逻辑非) e.g. String hql="from Commodity c where c.price between 100 and 4000 and c.category like '%电脑%'"; String hql1="from Commodity c where c.price between 100 and 4000 or c.category like '%电脑%'";