一般在需要获取2个结果结果集的数据使用union进行连接
select id,name from t1 union select id,name from t2
id | name |
---|---|
1 | jack |
2 | luce |
打上表的标签可以把重复的数据显示出来 或者使用 union all
select id,name from t1 union select id,name from t2
id | name |
---|---|
1 | jack |
2 | luce |
1 | jack |
select id,name,'t1' as tab_name from t1 union select id,name,'t2' as tab_name from t2
id | name | tab_name |
---|---|---|
1 | jack | t1 |
2 | luce | t2 |
1 | jack | t2 |
网友评论