From: Peter Brawley Date: February 16 2010 9:18pm Subject: Re: count children nodes List-Archive: http://lists.mysql.com/mysql/220717 Message-Id: <4B7B0BA8.6060603@earthlink.net> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------010800070909040002090105" --------------010800070909040002090105 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit David, >I need count the messages don'tread in a thread. Have a look at the edge list examples at http://www.artfulsoftware.com/mysqlbook/sampler/mysqled1ch20.html. PB ----- David Arroyo Menendez wrote: > Hello, > > I've the next table structure: > > CREATE TABLE tx_cc20_mensajes ( > uid int(11) NOT NULL auto_increment, > pid int(11) DEFAULT '0' NOT NULL, > tstamp int(11) DEFAULT '0' NOT NULL, > crdate int(11) DEFAULT '0' NOT NULL, > cruser_id int(11) DEFAULT '0' NOT NULL, > deleted tinyint(4) DEFAULT '0' NOT NULL, > hidden tinyint(4) DEFAULT '0' NOT NULL, > remitente int(11) DEFAULT '0' NOT NULL, > destinatario int(11) DEFAULT '0' NOT NULL, > padre int(11) DEFAULT '0' NOT NULL, > mensaje text, > leido tinyint(3) DEFAULT '0' NOT NULL, > > PRIMARY KEY (uid), > KEY parent (pid) > ); > > Where padre is the id of the parent message. I need count the messages don't > read in a thread. How can I do it? > > With > $query="select count(*) as num from tx_cc20_mensajes msj where hidden=0 and > deleted=0 and leido=0 and destinatario=".$uid." and remitente<>".$uid." and > (padre=".$est_row['uid']." or uid=".$est_row['uid'].")"; > I am counting only the first level, but I need count the rest of children > messages. What is the query? > > Thanks! > > > ------------------------------------------------------------------------ > > > No virus found in this incoming message. > Checked by AVG - www.avg.com > Version: 8.5.435 / Virus Database: 271.1.1/2691 - Release Date: 02/16/10 07:35:00 > > --------------010800070909040002090105--