update user1 as a inner join user2 as b on a.username=b.username set a.over='齐天大圣'
2017-09-13
没看到前面给的图是截图的吗?只给出想给你看的,说什么表不一样的都在想啥呢?
还有这个课的名字是开发技巧,你没有基础就来学技巧,难道不像是没有学会走路就像跑一样?去学基础去吧。
老师讲的挺好,加油!!!
还有这个课的名字是开发技巧,你没有基础就来学技巧,难道不像是没有学会走路就像跑一样?去学基础去吧。
老师讲的挺好,加油!!!
2017-09-12
再普及一个小知识
mysql-sql> select *
... from user1
... union
... select *
... from user2;
查询结果等价之前的,因为这两个table属性列数量相同,可以直接合并
mysql-sql> select *
... from user1
... union
... select *
... from user2;
查询结果等价之前的,因为这两个table属性列数量相同,可以直接合并
2017-09-09
那么怎么可以体现二者区别呢?
很简单,连接时对应字段一致。也就是:
select a.user_name,a.over,b.over
... from user1 a left join user2 b on a.user_name=b.user_name
... union
... select b.user_name,a.over,b.over
... from user1 a right join user2 b on a.user_name=b.user_name;
这样执行select后结果分别是8和9
很简单,连接时对应字段一致。也就是:
select a.user_name,a.over,b.over
... from user1 a left join user2 b on a.user_name=b.user_name
... union
... select b.user_name,a.over,b.over
... from user1 a right join user2 b on a.user_name=b.user_name;
这样执行select后结果分别是8和9
2017-09-09
为什么呢?
因为左外连接和右外连接时字段的顺序是不一样的,那么全连接时就意味着字段一是user_name 的连接而字段二是a.over和b.over的;连接字段三是b.over和a.over的连接。不存在重复值,此时union和union all等价,执行结果也是一样的
因为左外连接和右外连接时字段的顺序是不一样的,那么全连接时就意味着字段一是user_name 的连接而字段二是a.over和b.over的;连接字段三是b.over和a.over的连接。不存在重复值,此时union和union all等价,执行结果也是一样的
2017-09-09