赞
踩
第一种写法:
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper .and(wrapper -> wrapper.like("sim_1","1").or().like("sim_02", "2"));
queryWrapper .eq(“is_delete”, “0”);
对应sql语句:select * from user where (sim_1 LIKE ‘%1%’ or sim_02 like ‘%2%’ ) and is_delete=‘0’
另外一种写法(错误示范):
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper .eq("sim_1","测试").or().eq("sim_2","2");
queryWrapper .eq("sys_status","1");
对应SQL语句:select * from user where sim_1=‘测试’ or sim_2=‘2’ and sys_status =‘1’
你会发现sim_2=‘2’ 和sys_status ='1’成了并列条件。
两个实例:懂的都懂:
图2:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。