join queries

Поиск
Список
Период
Сортировка
От David M. Kaplan
Тема join queries
Дата
Msg-id 3AD71B12.677FB100@genes.bio.puc.cl
обсуждение исходный текст
Ответы Re: join queries  ("Oliver Elphick" <olly@lfix.co.uk>)
Список pgsql-general
Hi,

I have a query which seems like it should easy, but isnt.  I have two
tables, a and b that look like this:

a)

 id | c1
--+--
  1 | a
  2 | b
  3 | c

b)

 id | c2
--+--
  2 | b

and I would like to do a query which returns

 id | c1 | c2
--+--+--
  1 | a  |
  2 | b  | b
  3 | c  |

The simplest thing I could find was

SELECT a.*, (SELECT b.c2 WHERE a.id=b.id) AS c2;

This works, but is extremely slow for more complex examples.  Is there a
better way to do this in postgresql??  I think MS Access has inner and
outer joins to solve this problem.  Is there a postgresql equivalent?

Thanks for the help.

David Kaplan




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

Предыдущее
От: "Bob McCormick"
Дата:
Сообщение: Clustering with PostgreSQL?
Следующее
От: "Bob McCormick"
Дата:
Сообщение: Schema Import