Skip site navigation (1) Skip section navigation (2)

Re: BUG #3729: Query doesn't return the right answer

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Andrius Glozeckas <ndrs(at)systemap(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #3729: Query doesn't return the right answer
Date: 2007-11-08 14:49:28
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
Andrius Glozeckas wrote:

> I have a parent_type_id linking to group_type_id on the same table
> (group_type). I am trying to get the groups with certain parent_type_id (be
> it null or 17) and the number of their children in the same query:
> SELECT g1.*, COUNT(g2.*)
> FROM group_type g1 LEFT JOIN group_type g2 ON g1.group_type_id =
> g2.parent_type_id
> WHERE g1.parent_type_id = null 
> GROUP BY, g1.type, g1.choice, g1.multiple, g1.self_ref,
> g1.group_type_id, g1.parent_type_id
> But this doesn't give me any results, although there are a few records with
> parent_type_id = null and one with 17.

This is not a bug.  The correct syntax for testing for NULL is "column
IS NULL".  Do not use "column = NULL".

Alvaro Herrera                     
"Changing the world ... one keyboard at a time!"

In response to

pgsql-bugs by date

Next:From: David FetterDate: 2007-11-08 15:21:57
Subject: Re: BUG #3729: Query doesn't return the right answer
Previous:From: Andreas PflugDate: 2007-11-08 14:26:17
Subject: Re: BUG #3716: utf8 crash with replace

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group