Re: [SQL] Problems with distinct

2006-02-13 Thread Andreas Joseph Krogh
On Monday 13 February 2006 20:22, Tom Lane wrote: > Andreas Joseph Krogh <[EMAIL PROTECTED]> writes: > > Any idea why this works: > > SELECT distinct(g.groupname), g.id, g.p_id FROM onp_group g, onp_group g2 > > WHERE g.id IN(SELECT g2.id UNION SELECT group_id FROM onp_group_children > > WHERE chil

Re: [SQL] Problems with distinct

2006-02-13 Thread Owen Jacobson
Andreas Joseph Krogh wrote: > Any idea why this works: > > SELECT distinct(g.groupname), g.id, g.p_id FROM onp_group g, > onp_group g2 > WHERE g.id IN(SELECT g2.id UNION SELECT group_id FROM > onp_group_children WHERE > child_id = g2.id) > AND g2.id IN(1,2,109,105, 112); > > And not this: >

Re: [SQL] Problems with distinct

2006-02-13 Thread Tom Lane
Andreas Joseph Krogh <[EMAIL PROTECTED]> writes: > Any idea why this works: > SELECT distinct(g.groupname), g.id, g.p_id FROM onp_group g, onp_group g2 > WHERE g.id IN(SELECT g2.id UNION SELECT group_id FROM onp_group_children > WHERE > child_id = g2.id) > AND g2.id IN(1,2,109,105, 112); > And n