PostgreSQL DISTINCT 关键字。耳边二货

在 PostgreSQL 中,DISTINCT 关键字与 SELECT 语句一起使用,用于去除重复记录,只获取唯一的记录。

我们平时在操作数据时,有可能出现一种情况,在一个表中有多个重复的记录,当提取这样的记录时,DISTINCT 关键字就显得特别有意义,它只获取唯一一次记录,而不是获取重复记录。

语法
用于去除重复记录的 DISTINCT 关键字的基本语法如下:

SELECT DISTINCT column1, column2,.....columnN
FROM table_name
WHERE [condition]
实例
创建 COMPANY 表(下载 COMPANY SQL 文件 ),数据内容如下:
http://m.douguo.com/recipe/amp/2906302
http://m.douguo.com/recipe/mip/2906302
http://m.douguo.com/recipe/amp/2906461
http://m.douguo.com/recipe/mip/2906461
http://m.douguo.com/recipe/amp/2906473
http://m.douguo.com/recipe/mip/2906473
http://m.douguo.com/recipe/amp/2906474
http://m.douguo.com/recipe/mip/2906474
http://m.douguo.com/recipe/amp/2906492
http://m.douguo.com/recipe/mip/2906492
http://m.douguo.com/recipe/amp/2906519
http://m.douguo.com/recipe/mip/2906519
http://m.douguo.com/recipe/amp/2906537
http://m.douguo.com/recipe/mip/2906537
http://m.douguo.com/recipe/amp/2906539
http://m.douguo.com/recipe/mip/2906539
http://m.douguo.com/recipe/amp/2906565
http://m.douguo.com/recipe/mip/2906565
http://m.douguo.com/recipe/amp/2906588
http://m.douguo.com/recipe/mip/2906588
http://m.douguo.com/recipe/amp/2906608
http://m.douguo.com/recipe/mip/2906608
http://m.douguo.com/recipe/amp/2906633
http://m.douguo.com/recipe/mip/2906633
http://m.douguo.com/recipe/amp/2906683
http://m.douguo.com/recipe/mip/2906683
http://m.douguo.com/recipe/amp/2906712
http://m.douguo.com/recipe/mip/2906712
http://m.douguo.com/recipe/amp/2906745
http://m.douguo.com/recipe/mip/2906745
http://m.douguo.com/recipe/amp/2906751
http://m.douguo.com/recipe/mip/2906751
http://m.douguo.com/recipe/amp/2906763
http://m.douguo.com/recipe/mip/2906763
http://m.douguo.com/recipe/amp/2906782
http://m.douguo.com/recipe/mip/2906782
http://m.douguo.com/recipe/amp/2906803
http://m.douguo.com/recipe/mip/2906803
http://m.douguo.com/recipe/amp/2906839
http://m.douguo.com/recipe/mip/2906839
http://m.douguo.com/recipe/amp/2906884
http://m.douguo.com/recipe/mip/2906884
http://m.douguo.com/recipe/amp/2906890
http://m.douguo.com/recipe/mip/2906890
http://m.douguo.com/recipe/amp/2906888
http://m.douguo.com/recipe/mip/2906888
http://m.douguo.com/recipe/amp/2906921
http://m.douguo.com/recipe/mip/2906921
http://m.douguo.com/recipe/amp/2906943
http://m.douguo.com/recipe/mip/2906943
http://m.douguo.com/recipe/amp/2906948
http://m.douguo.com/recipe/mip/2906948
http://m.douguo.com/recipe/amp/2906965
http://m.douguo.com/recipe/mip/2906965
http://m.douguo.com/recipe/amp/2906966
http://m.douguo.com/recipe/mip/2906966
http://m.douguo.com/recipe/amp/2906990
http://m.douguo.com/recipe/mip/2906990
http://m.douguo.com/recipe/amp/2906999
http://m.douguo.com/recipe/mip/2906999
http://m.douguo.com/recipe/amp/2907047
http://m.douguo.com/recipe/mip/2907047
http://m.douguo.com/recipe/amp/2907049
http://m.douguo.com/recipe/mip/2907049
http://m.douguo.com/recipe/amp/2907369
http://m.douguo.com/recipe/mip/2907369
http://m.douguo.com/recipe/amp/2907391
http://m.douguo.com/recipe/mip/2907391
http://m.douguo.com/recipe/amp/2907446
http://m.douguo.com/recipe/mip/2907446
http://m.douguo.com/recipe/amp/2907449
http://m.douguo.com/recipe/mip/2907449
http://m.douguo.com/recipe/amp/2907452
http://m.douguo.com/recipe/mip/2907452
http://m.douguo.com/recipe/amp/2907531
http://m.douguo.com/recipe/mip/2907531
http://m.douguo.com/recipe/amp/2907538
http://m.douguo.com/recipe/mip/2907538
http://m.douguo.com/recipe/amp/2907551
http://m.douguo.com/recipe/mip/2907551
http://m.douguo.com/recipe/amp/2907553
http://m.douguo.com/recipe/mip/2907553
http://m.douguo.com/recipe/amp/2907571
http://m.douguo.com/recipe/mip/2907571
http://m.douguo.com/recipe/amp/2907573
http://m.douguo.com/recipe/mip/2907573
http://m.douguo.com/recipe/amp/2907595
http://m.douguo.com/recipe/mip/2907595
http://m.douguo.com/recipe/amp/2907631
http://m.douguo.com/recipe/mip/2907631
http://m.douguo.com/recipe/amp/2907632
http://m.douguo.com/recipe/mip/2907632
http://m.douguo.com/recipe/amp/2907635
http://m.douguo.com/recipe/mip/2907635
http://m.douguo.com/recipe/amp/2907660
http://m.douguo.com/recipe/mip/2907660
http://m.douguo.com/recipe/amp/2907665
http://m.douguo.com/recipe/mip/2907665
http://m.douguo.com/recipe/amp/2907672
http://m.douguo.com/recipe/mip/2907672
http://m.douguo.com/recipe/amp/2907671
http://m.douguo.com/recipe/mip/2907671
http://m.douguo.com/recipe/amp/2907682
http://m.douguo.com/recipe/mip/2907682
http://m.douguo.com/recipe/amp/2907709
http://m.douguo.com/recipe/mip/2907709
http://m.douguo.com/recipe/amp/2907737
http://m.douguo.com/recipe/mip/2907737
http://m.douguo.com/recipe/amp/2907743
http://m.douguo.com/recipe/mip/2907743
http://m.douguo.com/recipe/amp/2907744
http://m.douguo.com/recipe/mip/2907744
http://m.douguo.com/recipe/amp/2907781
http://m.douguo.com/recipe/mip/2907781
http://m.douguo.com/recipe/amp/2907786
http://m.douguo.com/recipe/mip/2907786
http://m.douguo.com/recipe/amp/2907789
http://m.douguo.com/recipe/mip/2907789
http://m.douguo.com/recipe/amp/2907825
http://m.douguo.com/recipe/mip/2907825
http://m.douguo.com/recipe/amp/2907826
http://m.douguo.com/recipe/mip/2907826
http://m.douguo.com/recipe/amp/2908007
http://m.douguo.com/recipe/mip/2908007
http://m.douguo.com/recipe/amp/2908081
http://m.douguo.com/recipe/mip/2908081
http://m.douguo.com/recipe/amp/2908122
http://m.douguo.com/recipe/mip/2908122
http://m.douguo.com/recipe/amp/2906273
http://m.douguo.com/recipe/mip/2906273
http://m.douguo.com/recipe/amp/2906321
http://m.douguo.com/recipe/mip/2906321
http://m.douguo.com/recipe/amp/2906338
http://m.douguo.com/recipe/mip/2906338
http://m.douguo.com/recipe/amp/2906363
http://m.douguo.com/recipe/mip/2906363
http://m.douguo.com/recipe/amp/2906372
http://m.douguo.com/recipe/mip/2906372
http://m.douguo.com/recipe/amp/2906411
http://m.douguo.com/recipe/mip/2906411
http://m.douguo.com/recipe/amp/2906562
http://m.douguo.com/recipe/mip/2906562
http://m.douguo.com/recipe/amp/2906578
http://m.douguo.com/recipe/mip/2906578
http://m.douguo.com/recipe/amp/2906579
http://m.douguo.com/recipe/mip/2906579
http://m.douguo.com/recipe/amp/2906580
http://m.douguo.com/recipe/mip/2906580
http://m.douguo.com/recipe/amp/2906596
http://m.douguo.com/recipe/mip/2906596
http://m.douguo.com/recipe/amp/2906610
http://m.douguo.com/recipe/mip/2906610
http://m.douguo.com/recipe/amp/2906615
http://m.douguo.com/recipe/mip/2906615
http://m.douguo.com/recipe/amp/2906616
http://m.douguo.com/recipe/mip/2906616
http://m.douguo.com/recipe/amp/2906650
http://m.douguo.com/recipe/mip/2906650
http://m.douguo.com/recipe/amp/2906655
http://m.douguo.com/recipe/mip/2906655
http://m.douguo.com/recipe/amp/2906662
http://m.douguo.com/recipe/mip/2906662
http://m.douguo.com/recipe/amp/2906672
http://m.douguo.com/recipe/mip/2906672
http://m.douguo.com/recipe/amp/2906681
http://m.douguo.com/recipe/mip/2906681
http://m.douguo.com/recipe/amp/2906685
http://m.douguo.com/recipe/mip/2906685
http://m.douguo.com/recipe/amp/2906697
http://m.douguo.com/recipe/mip/2906697
http://m.douguo.com/recipe/amp/2906710
http://m.douguo.com/recipe/mip/2906710
http://m.douguo.com/recipe/amp/2906736
http://m.douguo.com/recipe/mip/2906736
http://m.douguo.com/recipe/amp/2906755
http://m.douguo.com/recipe/mip/2906755
http://m.douguo.com/recipe/amp/2906766
http://m.douguo.com/recipe/mip/2906766
http://m.douguo.com/recipe/amp/2906786
http://m.douguo.com/recipe/mip/2906786
http://m.douguo.com/recipe/amp/2906798
http://m.douguo.com/recipe/mip/2906798
http://m.douguo.com/recipe/amp/2906813
http://m.douguo.com/recipe/mip/2906813
http://m.douguo.com/recipe/amp/2907079
http://m.douguo.com/recipe/mip/2907079
http://m.douguo.com/recipe/amp/2907130
http://m.douguo.com/recipe/mip/2907130
http://m.douguo.com/recipe/amp/2907325
http://m.douguo.com/recipe/mip/2907325
http://m.douguo.com/recipe/amp/2907358
http://m.douguo.com/recipe/mip/2907358
http://m.douguo.com/recipe/amp/2907365
http://m.douguo.com/recipe/mip/2907365
http://m.douguo.com/recipe/amp/2907432
http://m.douguo.com/recipe/mip/2907432
http://m.douguo.com/recipe/amp/2907447
http://m.douguo.com/recipe/mip/2907447
http://m.douguo.com/recipe/amp/2907476
http://m.douguo.com/recipe/mip/2907476
http://m.douguo.com/recipe/amp/2907528
http://m.douguo.com/recipe/mip/2907528
http://m.douguo.com/recipe/amp/2907750
http://m.douguo.com/recipe/mip/2907750
http://m.douguo.com/recipe/amp/2908054
http://m.douguo.com/recipe/mip/2908054
http://m.douguo.com/recipe/amp/2908079
http://m.douguo.com/recipe/mip/2908079
http://m.douguo.com/recipe/amp/2908082
http://m.douguo.com/recipe/mip/2908082
http://m.douguo.com/recipe/amp/2908120
http://m.douguo.com/recipe/mip/2908120
http://m.douguo.com/recipe/amp/2908123
http://m.douguo.com/recipe/mip/2908123
http://m.douguo.com/recipe/amp/2908146
http://m.douguo.com/recipe/mip/2908146
http://m.douguo.com/recipe/amp/2908200
http://m.douguo.com/recipe/mip/2908200
http://m.douguo.com/recipe/amp/2908201
http://m.douguo.com/recipe/mip/2908201

上一篇:【转】 前端笔记之CSS(上)语法&文本属性&块/行内元素&选择器&盒模型


下一篇:学习 Java ,是看书学习快,还是看视频学习快呢 ?