petit pb sur une requete SQL

Répondre
nygma
le 09/12/2004 à 13:18
nygma
Salut !

j'ai fait une chtite requete qui me renvoie les 10 derniers post sur 10 topic différents, sur un forum phpBB. mais la requete ne retourne que le PREMIER post de chaque topic, et non le dernier.

j'ai dû louper un épisode.....

SELECT TOPIC_TITLE, poster_id, post_time, post_text FROM phpbb_posts, phpbb_forums, phpbb_posts_text, phpbb_topics WHERE auth_view=0 AND phpbb_posts.post_id=phpbb_posts_text.post_id AND phpbb_posts.forum_id=phpbb_forums.forum_id AND phpbb_posts.topic_id=phpbb_topics.topic_id GROUP BY topic_title ORDER BY post_time DESC LIMIT 10;

Merci !
LA GLOBULE
le 09/12/2004 à 14:57
LA GLOBULE
Tu veux le dernier message de 10 sujets ? (10 messages au total)
Ou les 10 derniers messages de 10 sujets ? (100 messages au total)
nygma
le 09/12/2004 à 15:40
nygma
le dernier message de 10 sujets. (10 messages au total)

;=)

c'est pour mettre sur ma page d'entrée, pour inciter les gens à lire le forum.
nygma
le 09/12/2004 à 23:56
nygma
La structure des tables ?

ouh là, c'est un forum phpBB classique.
bouge pas, je t'extrait ça.
nygma
le 09/12/2004 à 23:57
nygma
-- --------------------------------------------------------

--
-- Structure de la table `phpbb_forums`
--

CREATE TABLE `phpbb_forums` (
`forum_id` smallint(5) unsigned NOT NULL default '0',
`cat_id` mediumint(8) unsigned NOT NULL default '0',
`forum_name` varchar(150) default NULL,
`forum_desc` text,
`forum_status` tinyint(4) NOT NULL default '0',
`forum_order` mediumint(8) unsigned NOT NULL default '1',
`forum_posts` mediumint(8) unsigned NOT NULL default '0',
`forum_topics` mediumint(8) unsigned NOT NULL default '0',
`forum_last_post_id` mediumint(8) unsigned NOT NULL default '0',
`prune_next` int(11) default NULL,
`prune_enable` tinyint(1) NOT NULL default '0',
`auth_view` tinyint(2) NOT NULL default '0',
`auth_read` tinyint(2) NOT NULL default '0',
`auth_post` tinyint(2) NOT NULL default '0',
`auth_reply` tinyint(2) NOT NULL default '0',
`auth_edit` tinyint(2) NOT NULL default '0',
`auth_delete` tinyint(2) NOT NULL default '0',
`auth_sticky` tinyint(2) NOT NULL default '0',
`auth_announce` tinyint(2) NOT NULL default '0',
`auth_vote` tinyint(2) NOT NULL default '0',
`auth_pollcreate` tinyint(2) NOT NULL default '0',
`auth_attachments` tinyint(2) NOT NULL default '0',
PRIMARY KEY (`forum_id`),
KEY `forums_order` (`forum_order`),
KEY `cat_id` (`cat_id`),
KEY `forum_last_post_id` (`forum_last_post_id`)
) TYPE=MyISAM;

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

--
-- Structure de la table `phpbb_posts`
--

CREATE TABLE `phpbb_posts` (
`post_id` mediumint(8) unsigned NOT NULL auto_increment,
`topic_id` mediumint(8) unsigned NOT NULL default '0',
`forum_id` smallint(5) unsigned NOT NULL default '0',
`poster_id` mediumint(8) NOT NULL default '0',
`post_time` int(11) NOT NULL default '0',
`poster_ip` varchar(8) NOT NULL default '',
`post_username` varchar(25) default NULL,
`enable_bbcode` tinyint(1) NOT NULL default '1',
`enable_html` tinyint(1) NOT NULL default '0',
`enable_smilies` tinyint(1) NOT NULL default '1',
`enable_sig` tinyint(1) NOT NULL default '1',
`post_edit_time` int(11) default NULL,
`post_edit_count` smallint(5) unsigned NOT NULL default '0',
PRIMARY KEY (`post_id`),
KEY `forum_id` (`forum_id`),
KEY `topic_id` (`topic_id`),
KEY `poster_id` (`poster_id`),
KEY `post_time` (`post_time`)
) TYPE=MyISAM AUTO_INCREMENT=865 ;

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

--
-- Structure de la table `phpbb_posts_text`
--

CREATE TABLE `phpbb_posts_text` (
`post_id` mediumint(8) unsigned NOT NULL default '0',
`bbcode_uid` varchar(10) NOT NULL default '',
`post_subject` varchar(60) default NULL,
`post_text` text,
PRIMARY KEY (`post_id`)
) TYPE=MyISAM;

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

--
-- Structure de la table `phpbb_topics`
--

CREATE TABLE `phpbb_topics` (
`topic_id` mediumint(8) unsigned NOT NULL auto_increment,
`forum_id` smallint(8) unsigned NOT NULL default '0',
`topic_title` char(60) NOT NULL default '',
`topic_poster` mediumint(8) NOT NULL default '0',
`topic_time` int(11) NOT NULL default '0',
`topic_views` mediumint(8) unsigned NOT NULL default '0',
`topic_replies` mediumint(8) unsigned NOT NULL default '0',
`topic_status` tinyint(3) NOT NULL default '0',
`topic_vote` tinyint(1) NOT NULL default '0',
`topic_type` tinyint(3) NOT NULL default '0',
`topic_first_post_id` mediumint(8) unsigned NOT NULL default '0',
`topic_last_post_id` mediumint(8) unsigned NOT NULL default '0',
`topic_moved_id` mediumint(8) unsigned NOT NULL default '0',
PRIMARY KEY (`topic_id`),
KEY `forum_id` (`forum_id`),
KEY `topic_moved_id` (`topic_moved_id`),
KEY `topic_status` (`topic_status`),
KEY `topic_type` (`topic_type`)
) TYPE=MyISAM AUTO_INCREMENT=193 ;
LA GLOBULE
le 10/12/2004 à 00:01
LA GLOBULE
En fait, donne juste les champs "importants" pour faire ton truc.

Donne nous une vue de ta base.
Répondre
LoadingChargement en cours