2017-08-13 60 views
0

做一个复杂的空调如果我想if子句的MyBatis的测试以下条件:如何MyBatis的

(x = null or x = '') and y != null and y != '' 

然而,当我把它放在<if test=...if内容不被添加到动态生成的SQL中,尽管x确实为空,并且y有一个值。如何在MyBatis中处理这样的条件?

+0

可能的复制https://stackoverflow.com/questions/14306949/mybatis-nested-conditions-in-where-clause?rq=1 –

回答

0

您正在分配x变量,而不是比较。更改

(x = null or x = '') and y != null and y != '' 

通过

(x == null or x == '') and y != null and y != '' 
+0

,或者使用''只选择一个结果而不选择其他结果。感谢捕捉明显。 – NuCradle