CASE t.sex WHEN '男' THEN '1' ELSE '0' END AS sex, sum(a.province) AS province FROM user t LEFT JOIN (select * from user_address) addr on t.id = addr.user_id RIGHT JOIN area a on addr.area_id = a.id WHERE ( addr.tel LIKE ? AND a.province <= ?) ORDER BY addr.id ...
sum(a.province) AS province FROM user t LEFT JOIN (select * from user_address) addr on t.id = addr.user_id RIGHT JOIN area a on addr.area_id = a.id WHERE ( addr.tel LIKE ? AND a.province <= ?) ORDER BY addr.id DESC0...
mybatis-plus-join mybatis-plus-join是mybatis plus的一个多表插件,上手简单,十分钟不到就能学会全部使用方式,只要会用mp就会用这个插件,仅仅依赖了lombok,而且是扩展mp的构造器并非更改原本的构造器,不会对原有项目产生一点点影响,相信大多数项目都有这俩插件,四舍五入就是没依赖。 mybatis-plus-join插件地址:...
方法在1.3.2版本后支持 .add("mp永远滴神","mpnb") .add("sum(users_age.id)","ageIdSum",false); // 这个为false就是代表不是字符串,会原样查询 在1.3.1版本后支持 }).end(); // 执行查询 usersService.joinList(wrapper,UsersVo.class); // 执行SQL select users.user_id, users.user_name...
SELECT t.id, t.name, t.sex, t.head_img, addr.tel, addr.address, CASE t.sex WHEN '男' THEN '1' ELSE '0' END AS sex, sum(a.province) AS province FROM user t LEFT JOIN (select * from user_address) addr on t.id = addr.user_id RIGHT JOIN area a on addr.area_id = a....
SELECT t.id, t.name, t.sex, t.head_img, addr.tel, addr.address, CASE t.sex WHEN '男' THEN '1' ELSE '0' END AS sex, sum(a.province) AS province FROM user t LEFT JOIN (select * from user_address) addr on t.id = addr.user_id RIGHT JOIN area a on addr.area_id = a....
SUM("SUM"), RAND("RAND"), COUNT("COUNT"), /** * 字符串 */ IFNULL("IFNULL"), CONCAT("CONCAT"), FORMAT("FORMAT"), REPLACE("REPLACE"), LOWER("LOWER"), UPPER("UPPER"), /** * 函数 */ CASE("CASE"), THEN("THEN"), END("END"), WHEN("WHEN"), ELSE("ELSE"); private fi...
数学:abs, avg, max, min, sum, rand, count; 字符串:ifNull, concat, format, replace, upper, lower; 控制流:case..then...when...else; 注意:部分函数可能不受某些数据库支持,请根据自己项目使用的数据库选择性使用 Select 如: // 查询分数,并根据分段给出评价JoinWrapper<ScoreDO,StudentDTO>wrapper...
("CASEt.sexWHEN'男'THEN'1'ELSE'0'ENDASsex") //求和函数 .select("sum(a.province)ASprovince") //自定义数据集 .leftJoin("(select*fromuser_address)addront.id= addr.user_id") .rightJoin("area a on addr.area_id = a.id") .like("addr.tel", "1") .le("a.province", "1") ....
t.id, t.name, t.sex, t.head_img, addr.tel, addr.address,CASEt.sexWHEN'男'THEN'1'ELSE'0'ENDASsex,sum(a.province)ASprovinceFROMusertLEFTJOIN(select*fromuser_address) addront.id = addr.user_idRIGHTJOINarea aonaddr.area_id = a.idWHERE( addr.telLIKE?ANDa.province <= ?)ORDERBYaddr...