Re: SELECT duplicates in a table

Поиск
Список
Период
Сортировка
От Kall, Bruce A.
Тема Re: SELECT duplicates in a table
Дата
Msg-id 41A22AFB.3090609@mayo.edu
обсуждение исходный текст
Ответ на Re: SELECT duplicates in a table  (vhikida@inreach.com)
Список pgsql-general
Thanks.  Worked like a charm!

Bruce


vhikida@inreach.com wrote:
> Try
>
> SELECT *
>   FROM mytable
>  WHERE (identification_number,date_of_birth) IN
>           (SELECT identification_number
>                 , date_of_birth
>              FROM mytable m2
>             GROUP BY identification_number,data_of_birth
>            HAVING COUNT(*) > 1
>           )
>
> There are other ways of doing it, perhaps more efficient.
>
> Vincent
>
>
>>I've look for a solution to this, but have only been able to find
>>solutions to delete duplicate entries in a table by deleting entries not
>>returned by SELECT DISTINCT.
>>
>>What sql should I use to SELECT entries in a table that have two
>>particular column values that match?
>>
>>For example, my_table has
>>name, phone number, identification_number, zip code, date of birth, and
>>city
>>
>>I want to SELECT rows from this table that have the same values in
>>identification and date of birth (duplicates) so I can have the user
>>look at them in order to figure out which one to delete.
>>
>>I tried something like:
>>
>>  $db_sql = "SELECT * FROM my_table GROUP BY identification_number
>>HAVING count(date_of_birth) > 1 ORDER BY name"
>>
>>but that doesn't seem to work.
>>
>>Thanks,
>>Bruce
>>
>>
>>---------------------------(end of broadcast)---------------------------
>>TIP 6: Have you searched our list archives?
>>
>>               http://archives.postgresql.org
>>
>
>
>

В списке pgsql-general по дате отправления:

Предыдущее
От: vhikida@inreach.com
Дата:
Сообщение: Re: SELECT duplicates in a table
Следующее
От: Edward Macnaghten
Дата:
Сообщение: Re: SELECT duplicates in a table