Good afternoon all,

I'm trying to get a count of users allocated to an event.
There may be none. I've created tables and populated it with
two events with no attendees. When I do a straight select statement
I get the expected result:

sqlite> SELECT
   ...>  event.id
   ...> , event.description
   ...> , event.attendees
   ...> , timeslot.start
   ...> , timeslot.stop
   ...> , people_event.people
   ...>  FROM event
   ...>  INNER JOIN event_timeslot ON event.id = event_timeslot.event
   ...>  INNER JOIN timeslot       ON event_timeslot.timeslot =
timeslot.id
   ...>  LEFT JOIN people_event ON event.id = people_event.event;
1|event 1|10|1000|1100|

It returns the one event that the joins match and NULL
for the people column as it should.

When I change one of the columns being returned the output
completely changes (note 'people_event.people' changed to
'count(people_event.people)' )

sqlite> SELECT
   ...>  event.id
   ...> , event.description
   ...> , event.attendees
   ...> , timeslot.start
   ...> , timeslot.stop
   ...> , COUNT(people_event.people)
   ...>  FROM event
   ...>  INNER JOIN event_timeslot ON event.id = event_timeslot.event
   ...>  INNER JOIN timeslot       ON event_timeslot.timeslot =
timeslot.id
   ...>  LEFT JOIN people_event ON event.id = people_event.event;
|||||0
sqlite>

Now the count is correct but all the other columns change to NULL ?

Any idea what causes this?

Thanks!

=====

---------------------------------

The Castles of Dereth Calendar: a tour of that art and architecture of the 
online game world of Asheron's Call
http://www.lulu.com/content/77264


                
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Helps protect you from nasty viruses. 
http://promotions.yahoo.com/new_mail

Reply via email to