| От | Chris Fossenier |
|---|---|
| Тема | Populating a Table |
| Дата | |
| Msg-id | s9fc22df.060@mail.pcguru.com обсуждение исходный текст |
| Список | pgsql-admin |
Hello, I'm sure I'll be flagged as a moron for asking this question, so be it. I have some tables of info with no primary keys. As a result the field I want to key on is repeated. My plan is to do aDISTINCT select from the un-keyed table into another table that does have constraints. Here is what I thought would work: INSERT INTO table2 SELECT DISTINCT(key), name, field1, field2 FROM table1; When I issue this statement it tells me that you cannot put in duplicate values into my key field. Why does it do that? If I issue the following statement I get exactly what I want: SELECT DISTINCT(phone) from table1; Am I using the DISTINCT function incorrectly? Is it taking all of the field and using them to create a distinct row? Any help would be appreciated. Chris.
В списке pgsql-admin по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера