【unionall】...内容无重叠用selectunion和selectunionall查询...

发布时间:2021-04-04 01:49:50

两张表,结构一样,内容无重叠,用select union和select union all查询结果是( )A.有可能相同B.有可能不同 数学

网友回答

【答案】 内容无重叠如何解释
  
  union 会自动筛选重复数据,这个重复不论是在a表中重复的,还是a、b两个表的记录重复的,都会筛选掉.效果相当于distincdt
  union all则会返回所有记录
  
  举例:
  A表数据
  1
  2
  B表数据
  3
  4
  
  select * from a union select * from b 结果
  1
  2
  3
  4
  
  select * from a union all slect * from b 结果同上
  
  
  
  
  A表数据
  1
  2
  B表数据
  2
  4
  
  select * from a union select * from b 结果
  1
  2
  4
  
  select * from a union all slect * from b 结果
  1
  2
  2
  4
以上问题属网友观点,不代表本站立场,仅供参考!