List:General Discussion« Previous MessageNext Message »
From:Martin Ramsch Date:September 20 1999 7:49pm
Subject:Re: why does this query return empty set?
View as plain text  
On Mon, 1999-09-20 12:23:29 -0400, Troy Grady wrote:
> Well, that works too.  :) Though it also fails if the visitor table
> is empty.

For this problem, you'll probably need a LEFT JOIN.

> > But I've a question:
> > > SELECT [...] FROM [...]
> > > WHERE [...]
> > > AND IF(session.id_visitor > 0, visitor.id = session.id_visitor,
> pageview.id
> > > = pageview.id)
> > > [...]
> >
> > This IF() term is equivalent to:
> >   AND ( ( session.id_visitor > 0  AND visitor.id = session.id_visitor )
> >         OR
> >         ( session.id_visitor <= 0 AND pageview.id = pageview.id )
> >       )
> > Is that, what you really wanted?
[...]
> Would there be any advantage to using your method over the IF()
> function?

No, actually your version using IF() even might be faster!  I just was
wondering ...

Regards,
  Martin
-- 
Martin Ramsch <m.ramsch@stripped> <URL: http://home.pages.de/~ramsch/ >
PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26  E4 EC 80 58 7B 31 3A D7
Thread
why does this query return empty set?Troy Grady19 Sep
  • Re: why does this query return empty set?Paul DuBois19 Sep
  • Re: why does this query return empty set?Troy Grady20 Sep
    • Re: why does this query return empty set?Martin Ramsch20 Sep