What is the best way to merge two disjoint tables?
| От | Chansup Byun |
|---|---|
| Тема | What is the best way to merge two disjoint tables? |
| Дата | |
| Msg-id | 46E176B3.7040802@sun.com обсуждение исходный текст |
| Ответы |
Re: What is the best way to merge two disjoint tables?
|
| Список | pgsql-general |
Hi Gurus, I have two disjoint tables, for examples, of user lists. Some users appear both tables. They may or may not have the same u_id. Some users only appear one table. I would like to merge tableB into tableA with the condition that each user has a unique id. Also I would like to keep u_id in the tableB. This requires to modify u_id of tableA if there are matching users but different u_id. Also those users only in tableA should change their u_id, if needed, to avoid any conflict with u_id from tableB. Can someone show me an example SQL statement? tableA: u_user | u_id ----------+------ user1 | 46 user2 | 30 user4 | 22 user5 | 48 user7 | 6 user9 | 1 user11 | 45 user12 | 33 tableB: u_user | u_id ----------+------ user1 | 46 user2 | 30 user3 | 22 user6 | 48 user8 | 6 user10 | 1 Thanks, - Chansup
В списке pgsql-general по дате отправления: