您好,登录后才能下订单哦!
准备(两张表t1,t2):
表t1:
mysql> select * from t1;
+-------+---------+
| t1_id | t1_name |
+-------+---------+
| 1 | t1_1 |
| 2 | t1_2 |
+-------+---------+
2 rows in set (0.02 sec)
表t2:
mysql> select * from t2;
+-------+---------+
| t2_id | t2_name |
+-------+---------+
| 2 | t2_2 |
| 3 | t2_3 |
+-------+---------+
2 rows in set (0.03 sec)
并集实例:
mysql> select t1.t1_id,t2.t2_id,t1.t1_name from t1 left join t2 on t1.t1_id=t2.t2_id;
+-------+-------+---------+
| t1_id | t2_id | t1_name |
+-------+-------+---------+
| 1 | NULL | t1_1 |
| 2 | 2 | t1_2 |
+-------+-------+---------+
2 rows in set (0.02 sec)
交集实例:
mysql> select t1.t1_id,t2.t2_id,t1.t1_name from t1,t2 where t1.t1_id=t2.t2_id;
+-------+-------+---------+
| t1_id | t2_id | t1_name |
+-------+-------+---------+
| 2 | 2 | t1_2 |
+-------+-------+---------+
1 row in set (0.01 sec)
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。