Re: Finding multiple events of the same kind
От
Frank Bax
Тема
Re: Finding multiple events of the same kind
Дата
Msg-id
5.2.1.1.0.20060611092112.04a773f0@pop6.sympatico.ca
Ответ на
Finding multiple events of the same kind (Leif B. Kristensen)
Список
Дерево обсуждения
Finding multiple events of the same kind "Leif B. Kristensen" <leif@solumslekt.org>
Re: Finding multiple events of the same kind Frank Bax <fbax@sympatico.ca>
Re: Finding multiple events of the same kind "Leif B. Kristensen" <leif@solumslekt.org>
Re: Finding multiple events of the same kind Richard Broersma Jr <rabroersma@yahoo.com>
Re: Finding multiple events of the same kind "Leif B. Kristensen" <leif@solumslekt.org>
Re: Finding multiple events of the same kind "Leif B. Kristensen" <leif@solumslekt.org>
At 08:53 AM 6/11/06, Leif B. Kristensen wrote: >I've got two tables: > >CREATE TABLE events ( > event_id INTEGER PRIMARY KEY, > tag_fk INTEGER NOT NULL REFERENCES tags (tag_id), > place_fk INTEGER NOT NULL REFERENCES places (place_id), > event_date CHAR(18) NOT NULL DEFAULT '000000003000000001', > sort_date DATE NOT NULL DEFAULT '40041024BC', > event_note TEXT NOT NULL DEFAULT '' >); > >CREATE TABLE participants ( > person_fk INTEGER NOT NULL REFERENCES persons (person_id), > event_fk INTEGER NOT NULL REFERENCES events (event_id) ON DELETE >CASCADE, > is_principal BOOLEAN NOT NULL DEFAULT false, > PRIMARY KEY (person_fk, event_fk) >); > >The table "participants" is of course a many-to-many relation >between "events" and "persons". My problem is that it's entirely >possible to insert eg. multiple birth events for one person, and I'd >like to be able to spot these. Something like this should get a list of person_fk values that have more than one birth date: SELECT participants.person_fk, count(participants.person_fk) FROM events, participants WHERE events.event_id = participants.event_fk AND events.tag_fk in (2,62,1035) GROUP BY participants.person_fk HAVING count(participants.person_fk) > 1
В списке pgsql-sql по дате отправления