簡體   English   中英

從postgres中的表中選擇所有重復項

[英]select all duplicates from a table in postgres

有沒有一種簡單的方法可以從Postgres表中選擇所有重復項? 無需加入或任何花哨的東西。 我在堆棧上找到的所有內容都是關於涉及表中多個字段的聯接和重復項。

我只需select * from table where table contains duplicate entries

有任何想法嗎?

Postgres中的表定義:

scotchbox=# \d+ eve_online_market_groups

                                                           Table "public.eve_online_market_groups"
   Column   |              Type              |                               Modifiers                               | Storage  | Stats target | Description 
------------+--------------------------------+-----------------------------------------------------------------------+----------+--------------+-------------
 id         | integer                        | not null default nextval('eve_online_market_groups_id_seq'::regclass) | plain    |              | 
 name       | character varying(255)         | not null                                                              | extended |              | 
 item_id    | integer                        | not null                                                              | plain    |              | 
 slug       | character varying(255)         | not null                                                              | extended |              | 
 created_at | timestamp(0) without time zone |                                                                       | plain    |              | 
 updated_at | timestamp(0) without time zone |                                                                       | plain    |              | 
Indexes:
    "eve_online_market_groups_pkey" PRIMARY KEY, btree (id)
Has OIDs: no

您可能正在尋找類似這樣的東西。

  SELECT columns_that_define_duplicates -- SELECT item_id, name, slug perhaps?
       , count(*)
    FROM eve_online_market_groups
GROUP BY columns_that_define_duplicates
  HAVING count(*) > 1;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM