mybatisplus查询视图
关键字:mybatisplus子查询、mybatisplus查询虚拟表、mybatisplus查询临时表
将@TableName的值写成临时表的sql语句并给予别名,就可以像正常表一样查询了。
show your code:
@TableName("(select * from msg join content on msg.id = content.mid where msg.deleted = 0) msg_view")
@Data
public class MsgView {
private Integer id;
private Integer fromUser;
private Integer toUser;
private String content;
}
当然也可以再Mapper里写自己的查询方法,自己写sql。不过既然来查了就是还想保持mybatisplus的风格,用queryWrapper。
参考链接:https://blog.csdn.net/AS_JOPO/article/details/124313664