MyBatis Plus QueryWrapper: Ordering Coaches by Work Status and Name
{"title":"MyBatis Plus QueryWrapper: Ordering Coaches by Work Status and Name","description":"This guide demonstrates how to use MyBatis Plus' QueryWrapper to order a list of coaches by their work status (prioritizing those with a work status) and then by their name using a custom SQL query.","keywords":"MyBatis Plus, QueryWrapper, SQL, Ordering, Work Status, Name, Coaches, Database, Java, Programming","content":"java\nQueryWrapper<Coach> queryWrapper = new QueryWrapper<>();\nqueryWrapper.eq(\"admin_id\", admin.getAdminId());\nqueryWrapper.orderByAsc(\"SUBSTR(CONVERT(real_name USING gbk), 1, 1)\");\n\nqueryWrapper.orderByDesc(\"CASE WHEN work_status IS NULL THEN 1 ELSE 0 END\");\n\nList<Coach> coaches = coachMapper.selectList(queryWrapper);\n"}
原文地址: https://www.cveoy.top/t/topic/pZSv 著作权归作者所有。请勿转载和采集!