Ciao a tutti, provo a disturbarvi con una richiesta...
ho un forum la cui tabella principale é la seguente:
Ho usato il grassetto sui due campi problematici. Il campo subject contiene il titolo del post e della sua replica, ad esempio:codice:CREATE TABLE `forum_messages` ( `id` int(11) NOT NULL auto_increment, `parent` int(11) default '0', `thread ` int(11) default '0', `catid` int(11) NOT NULL default '0', `name` tinytext, `userid` int(11) NOT NULL default '0', `email` tinytext, `subject ` tinytext, `time` int(11) NOT NULL default '0', `ip` varchar(15) default NULL, `topic_emoticon` int(11) NOT NULL default '0', `locked` tinyint(4) NOT NULL default '0', `hold` tinyint(4) NOT NULL default '0', `ordering` int(11) default '0', `hits` int(11) default '0', `future3` varchar(25) default NULL, PRIMARY KEY (`id`), KEY `thread` (`thread`), KEY `id` (`id`), KEY `parent` (`parent`), KEY `catid` (`catid`), KEY `ip` (`ip`), KEY `userid` (`userid`) ) TYPE=MyISAM AUTO_INCREMENT=1770 ;
"Argomento 1"
"Re: Argomento 1"
"Re: Argomento 1"
"Argomento 2"
"Re: Argomento 1"
"Re: Argomento 2"
e quello che unisce i vari post e sottopost preceduti da Re: é il campo thread che avrà per tutti questi il medesimo valore:
subject="Argomento 1" , thread=1
subject="Re: Argomento 1" , thread=1
subject="Re: Argomento 1" , thread=1
subject="Argomento 2" , thread=2
subject="Re: Argomento 1" , thread=1
subject="Re: Argomento 2" , thread=2
Ora che ho spiegato la struttura, vengo al quesito, mi occorrerebbero una o più query che mi interrogassero la tabella individuando gli ultimi 5 Argomenti o Topic, senza il "Re:", contando per ciascuno quante risposte ha avuto e l'ultimo autore che ha scritto che si individua dal campo name. Mi rendo conto che non siete qui a risolvere problemi altrui, mi basterebbe risolvere i problemi un pò alla volta.
Ho una query molto semplice che mi individua semplicemente le ultime righe inserite nella tabella e non le raggruppa per Argomenti:
ed é ovvio che non mi basta, grazie davvero in anticipocodice:$database->setQuery("SELECT * from forum_messages order by time desc limit 5");

Rispondi quotando
