List:General Discussion« Previous MessageNext Message »
From:David Arroyo Menendez Date:February 16 2010 4:27pm
Subject:count children nodes
View as plain text  
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!

Thread
count children nodesDavid Arroyo Menendez16 Feb
  • RE: count children nodesGavin Towey16 Feb
  • Re: count children nodesPeter Brawley16 Feb
    • Re: count children nodesDavid Arroyo Menendez17 Feb