Select Unique 和 Select Distinct 之间的区别 [英] Difference between Select Unique and Select Distinct

查看:41
本文介绍了Select Unique 和 Select Distinct 之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为这些是同义词,但我在 Microsoft SQL 中编写了以下内容:

I thought these were synonomous, but I wrote the following in Microsoft SQL:

Select Unique col from 
     (select col from table1 union select col from table2) alias

它失败了.将其更改为

Select Distinct col from 
     (select col from table1 union select col from table2) alias

修复了它.谁能解释一下?

fixed it. Can someone explain?

推荐答案

SELECT UNIQUE 是 Oracle 的 SQL 风格所支持的旧语法.它与 SELECT DISTINCT 同义.

SELECT UNIQUE is old syntax supported by Oracle's flavor of SQL. It is synonymous with SELECT DISTINCT.

使用SELECT DISTINCT,因为这是标准SQL,SELECT UNIQUE是非标准的,在Oracle以外的数据库品牌中,SELECT UNIQUE> 可能根本无法识别.

Use SELECT DISTINCT because this is standard SQL, and SELECT UNIQUE is non-standard, and in database brands other than Oracle, SELECT UNIQUE may not be recognized at all.

这篇关于Select Unique 和 Select Distinct 之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆