yulichang / mybatis-plus-join

支持连表查询的mybatis-plus,mybatis-plus风格的连表操作提供wrapper.leftJoin(),wrapper.rightJoin()等操作
https://yulichang.github.io/mybatis-plus-join-doc/
Apache License 2.0
1.01k stars 115 forks source link

两次关联相同表, setlectFunc concat(%s, %s) ,如何设置相同表的别名 #55

Closed Tyebile closed 3 months ago

Tyebile commented 1 year ago
MPJLambdaWrapper<Transfer> transferWrapper = new MPJLambdaWrapper<Transfer>()
                .selectFunc("concat(%s, %s)", arg -> arg.accept(Account::getAccountName, Account::getAccountName), Trade::getAccountName)
                .leftJoin(Account.class, "af", Account::getId, Transfer::getAccountFromId)
                .leftJoin(Account.class, "at", Account::getId, Transfer::getAccountToId)

对应sql

SELECT concat(af.account_name, af.account_name) AS accountName FROM transfer t LEFT JOIN account af ON (af.id = t.account_from_id) LEFT JOIN account at ON (at.id = t.account_to_id);

请问如何做到这种效果, concat(at,account_name, af.account_name)

SELECT concat(af.account_name, at.account_name) AS accountName FROM transfer t LEFT JOIN account af ON (af.id = t.account_from_id) LEFT JOIN account at ON (at.id = t.account_to_id);
yulichang commented 3 months ago

https://github.com/yulichang/mybatis-plus-join/issues/106