I need help coming up with a particular query...
I need a list of the THREADS sorted by the most recent TOPIC added.
Note: I just recently added the last_updated field to tblThreads so it is not functioning the way I wish,
plus this field is set anytime there is any activity.
Here are the related tables:
CREATE TABLE `tblThreads` (
`threadID` smallint(4) unsigned zerofill NOT NULL auto_increment,
`threadTitle` varchar(255) NOT NULL default '',
`threadCreated` datetime default NULL,
`last_updated` datetime default NULL,
`created_by` varchar(25) default NULL,
PRIMARY KEY (`threadID`)
) ENGINE=MyISAM AUTO_INCREMENT=154 DEFAULT CHARSET=latin1 COMMENT='Forum threads';
CREATE TABLE `tblTopics` (
`topicID` smallint(4) unsigned zerofill NOT NULL auto_increment,
`topicTitle` varchar(255) NOT NULL default '',
`topicBody` text NOT NULL,
`topicPoster` varchar(128) NOT NULL default '',
`topicPosterEmail` varchar(64) NOT NULL default '',
`topicPosted` datetime NOT NULL default '0000-00-00 00:00:00',
`created_by` int(11) NOT NULL default '0',
PRIMARY KEY (`topicID`)
) ENGINE=MyISAM AUTO_INCREMENT=6357 DEFAULT CHARSET=latin1 COMMENT='Thread topics';
CREATE TABLE `tblTopicsThreadsLink` (
`threadID` smallint(4) unsigned zerofill NOT NULL default '0000',
`topicID` smallint(4) unsigned zerofill NOT NULL default '0000',
UNIQUE KEY `UNIQUE` (`threadID`,`topicID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Threads to topics link table';
Thanks you so much for any suggestions or advice or query!