Re: master-detail relationship and count
| От | Richard Huxton |
|---|---|
| Тема | Re: master-detail relationship and count |
| Дата | |
| Msg-id | 200211291035.12923.dev@archonet.com обсуждение исходный текст |
| Ответ на | master-detail relationship and count (Gary Stainburn <gary.stainburn@ringways.co.uk>) |
| Список | pgsql-sql |
On Friday 29 Nov 2002 10:06 am, Gary Stainburn wrote: > Hi folks. > > I've got a master detail relationship where I have a railway route table > listing landmarks along the route, and a Links table listing URL's > associated with that landmark. Listed below: > > How can I do a query showing the landmark ID, the landmark name, and a > count of links associated with that landmark. Below is a SQL statement > that although is illegal, gives a good idea of what I'm looking for. > > select r.rtid, r.rtname, l.count(*) from route r, links l where l.lktype = > 'R' and l.lklid = r.rtid; You'll want to GROUP BY SELECT r.rtid, r.rtname, l.count(*) FROM route r, links l WHERE l.lktype='R' AND l.lklid=r.rtid GROUP BY r.rtid, r.rtname; -- Richard Huxton
В списке pgsql-sql по дате отправления: