Re: switching from mysql

Поиск
Список
Период
Сортировка
От Helge Bahmann
Тема Re: switching from mysql
Дата
Msg-id Pine.LNX.4.21.0111161822060.30595-100000@lothlorien.stunet2.tu-freiberg.de
обсуждение исходный текст
Ответ на Re: switching from mysql  (Brad Hilton <bhilton@vpop.net>)
Список pgsql-novice
On 16 Nov 2001, Brad Hilton wrote:
> The example I gave was a simple one to demonstrate my problem.  Let me
> give a better example.  Let's say I have 3 tables: items, stores, and
> store_items.  'store_items' maps items to stores.  If I want to select
> all items that are in at least one store, I currently do:
>
> select items.* from items, store_items where items.id =
> store_items.item_id group by items.id
>
> Is there a better way to do this query?

SELECT DISTINCT ON (items.id) items.* FROM items
  JOIN store_items ON store_items.id = items.id

regards
--
Helge Bahmann <bahmann@math.tu-freiberg.de>             /| \__
Network admin, systems programmer                      /_|____\
                                                     _/\ |   __)
$ ./configure                                        \\ \|__/__|
checking whether build environment is sane... yes     \\/___/ |
checking for AIX... no (we already did this)            |


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

Предыдущее
От: Jason Earl
Дата:
Сообщение: Re: Perl and pgsql...
Следующее
От: "Brett W. McCoy"
Дата:
Сообщение: Re: Perl and pgsql...