关于spring boot xml 文件的 sql 语句

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语句应该怎么写

用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}

```

select t1.*, t2.sname from user as t1 join simple as t2 on t1.id = t2.id where t1.id = #{id}