List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:September 18 1999 11:37pm
Subject:Re: why does this query return empty set?
View as plain text  
At 6:38 PM -0500 9/18/99, Troy Grady wrote:
>Folks-
>
>>From a web log analyzer program based on 3.22.22:
>
>Even when the "IF" statements evaluate such that no data is being selected
>from the "visitor" table, this query only works when the "visitor" table has
>rows in it.  Otherwise, it always returns empty set.  No errors, just empty
>set.  Any idea why?

The SELECT evaluates the WHERE clause against the cartesian product of
the tables.  If any of the tables is empty, that product is empty.
Result: no rows.


>
>Regards,
>
>Troy
>
>---
>
>SELECT
>pageview.id as 'Pageview #',
>pageview.id_session as 'Session #',
>IF(session.id_visitor > 0, visitor.unam, '') as 'Visitor',
>pageview.request_uri as 'Page Viewed',
>pageview.remote_addr as 'From IP address',
>DATE_FORMAT(pageview.creation, '%c/%d/%Y, %l:%i.%S %p') as 'When'
>
>FROM
>pageview,
>session,
>visitor
>
>WHERE
>session.id = pageview.id_session
>AND IF(session.id_visitor > 0, visitor.id = session.id_visitor, pageview.id
>= pageview.id)
>
>ORDER BY
>pageview.creation desc
>
>
>________________________________
>Troy Grady, Managing Director
>Grady Levkov & Company, Inc.
>580 Broadway, Suite 903
>New York NY, 10012
>
>212-925-0900 x 101 (v)
>212-925-0200          (f)
>
>
>---------------------------------------------------------------------
>Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
>posting. To request this thread, e-mail mysql-thread13549@stripped
>
>To unsubscribe, send a message to the address shown in the
>List-Unsubscribe header of this message. If you cannot see it,
>e-mail mysql-unsubscribe@stripped instead.


--
Paul DuBois, paul@stripped
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