How to "paste two tables side-by-side"?

Поиск
Список
Период
Сортировка
От Kynn Jones
Тема How to "paste two tables side-by-side"?
Дата
Msg-id c2350ba40802270439o17b839d2laac918ed0c11796d@mail.gmail.com
обсуждение исходный текст
Ответы Re: How to "paste two tables side-by-side"?
Re: How to "paste two tables side-by-side"?
Список pgsql-general
Suppose I have two tables, A and B, with k(A) and k(B) columns respectively, and let's assume to begin with that they have the same number of rows r(A) = r(B) = r.

What's the simplest way to produce a table C having r rows and k(A) + k(B) columns, and whose i-th row consists of the k(A) columns of the i-th row of A followed by the k(B) columns of the i-th row of B (for i = 1,...,r)?  (By "i-th row of A" I mean the i-th row of the listing one would get from "SELECT * FROM A", and likewise for B.)

The question could be generalized slightly to the case where the numbers of rows r(A) and r(B) are not equal.  For example, if r(A) < r(B), the desired table C would have r(B) rows, and the first k(A) columns of its last r(B) - r(A) rows would be nulls, reminiscent of a table produced by a right outer join.

Also, what's the technical term for this type of operation on two tables?

Thanks!

kynn

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

Предыдущее
От: Gordon
Дата:
Сообщение: Re: Query meltdown: caching results
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: autovacuum not freeing up unused space on 8.3.0