MybatisPlus中like查询匹配多个字段用法

写法如下:

QueryWrapper<SrmMdmSupplierAll> query = new QueryWrapper<>();
        query.eq("DISABLED", Constant.EnabledOrDisabled.ENABLED);
        query.eq("EMPLOYEE_CODE", CurrentUserHolder.getCurrentEmployeeCode());
        if (StringUtils.isNotEmpty(queryCommonVo.getKeywords())) {
            query.and(wrapper -> wrapper.like("VENDOR_FULL_NAME",queryCommonVo.getKeywords())
                                        .or()
                                        .like("VENDOR_CODE", queryCommonVo.getKeywords())
                                        .or()
                                        .like("VENDOR_ID",queryCommonVo.getKeywords()));
        }
        query.orderByDesc("UPDATE_DATE");

控制台打印sql语句如下:

SELECT * FROM SRM_MDM_SUPPLIER_ALL 
WHERE DISABLED = 0
AND EMPLOYEE_CODE = '03426'
AND (VENDOR_FULL_NAME LIKE '%1183%' OR VENDOR_CODE LIKE '%1183%' OR VENDOR_ID LIKE '%1183%') 


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *