select t1.*, t2.sname from user as t1 join simple as t2 on t1.id = t2.id;
这是关联查询,根据id查询两个表
select * from user where id = #{id}
这是根据id查询表
我现在想把这两个功能结合在一起,我的sql语句应该怎么写
关于spring boot xml 文件的 sql 语句
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
熊泽-学习中的苦与乐 2021-09-01 16:20关注用union就行
select t1.*, t2.sname from user as t1 join simple as t2 on t1.id = t2.id; UNION ALL select *,'' sname from user where id = #{id}```
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报