| От | Rick Schumeyer |
|---|---|
| Тема | SQL subquery question |
| Дата | |
| Msg-id | 455B1604.4090309@ieee.org обсуждение исходный текст |
| Ответы |
Re: SQL subquery question
|
| Список | pgsql-general |
I think this can be done with one SQL statement, but I'm not sure. I have two tables: table t contains key k, another field f, and a bunch of other stuff. In a poor design decision, table tsubset contains a small number of "pointers" to t. I should have used the k column; instead I used the f column (it is unique, but not the primary key). I want to fix this. I altered tsubset to have two columns, f and k, where k will be a foreign key referencing t(k). I now need to copy all the k values from t to tsubset. I think I want to do something like this: foreach f in tsubset update tsubset set k=(select k from t, tsubset where t.f=f); end Can this be done with one SQL statement?
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера