mysql - How to join my "clients" and "messages" tables? -


there 2 tables:

clients ___________ idclient int login varchar  messages ___________ idmessage int datewakeup datetime .... other fields 

i need each client count number of entries in table messages in given range of time. tried this:

select c.login, count(m.idmessage) clients c, messages m     m.idclient=c.idclient , m.datewakeup>'2010-09-01 00:00:01'     , m.datewakeup<'2010-10-01 00:00:01'; 

it not working.

when using count(...), have group by results:

select c.login, count(m.idmessage) clients c, messages m m.idclient=c.idclient , m.datewakeup>'2010-09-01 00:00:01' , m.datewakeup<'2010-10-01 00:00:01' group c.login 

Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -