SQL中的union和join很像一对(a couple)。
从操作结果二维表(二维平面)来看:
union的语义是上下方向连接的;
join的语义是左右方向连接的。
对于union,可进行如下实验观察结果(经典的SQL Injection常使用union):
- select name from students where id = 1 or id =2;
- select name from students where id = 1
- union
- select name from students where id = 2;
- select name from students where id = 2
- union
- select name from students where id = 1;
对于join,分为inner join和outer join。
其中:
inner join即默认语义join。
outer join分为:left outer join & right outer join & full(left+right) outer join。
阅读(1337) | 评论(2) | 转发(0) |