创建user1

mysql> select id from user1;
+------+
| id   |
+------+
|    1 |
|    2 |
|    3 |
+------+
3 rows in set (0.00 sec)

创建user2

mysql> seslect id from user2;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'seslect id from user2\' at line 1
mysql> select id from user2;
+------+
| id   |
+------+
|    1 |
|    1 |
|    2 |
|    2 |
+------+
4 rows in set (0.00 sec)

 

连表语句

mysql> select user1.id,user2.id from user1 left join user2 on user1.id = user2.id;
+------+------+
| id   | id   |
+------+------+
|    1 |    1 |
|    1 |    1 |
|    2 |    2 |
|    2 |    2 |
|    3 | NULL |
+------+------+
5 rows in set (0.15 sec)

 

版权声明:本文为jinfanfu原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/jinfanfu/p/10920133.html