Thread: select returning mysterious null rows

select returning mysterious null rows

From
webmaster@duluoz.net
Date:
Hi-
 I've got the following query:

select d.domain, p.lname, b.period, b.billed_thru,sum(i.monthly*b.period*discount(b.period)::float) as amountfrom
billingb, domain d, opt_info i,opt_list_domains l, plans pwhere b.billed_thru <= '$today'and b.domain = d.domainand
l.domain= d.domainand i.sname = l.optand p.sname = d.base_plangroup by domain, lname, period, billed_thru
 

It works fine when there are any matching tuples, but when there are
no matches, I get a row returned anyway, with all null fields.  The
null tuple isn't returned if any other tuples are -- only by itself.
Can anybody explain what's happening here?  I'm using PostgreSQL
6.5.3, and I've seen this behaviour both in psql and through PHP.

-mike

-- 

Mike Glover                            webmaster@duluoz.net
Duluoz Networks                        http://www.duluoz.net