mybatis-plus如何多表查询
MyBatis-Plus可以通过多种方式进行多表查询,以下是其中的一些方法:
1.使用注解方式 可以使用MyBatis-Plus提供的@Sql注解来自定义SQL语句进行多表查询,例如:
@Sql("select u.*, a.* from user u left join article a on u.id = a.user_id where u.id = #{userId}") UserAndArticle selectUserAndArticle(@Param("userId") Long userId);MyBatis-Plus可以通过多种方式进行多表查询,以下是其中的一些方法: 1.使用注解方式 可以使用MyBatis-Plus提供的@Sql注解来自定义SQL语句进行多表查询,例如: @Sql("select u.*, a.* from user u left join article a on u.id = a.user_id where u.id = #{userId}") UserAndArticle selectUserAndArticle(@Param("userId") Long userId);
下一篇:
MySQL手动恢复数据库测试操作