So, I have 2 tables for private messages. One is for the PMs themselves, the other is for their recipients.
What's odd though is, when I'm no longer listed in the recipients table for a specific PM, it still gets selected, if I'm the one who created it. I dunno why it happens, this is the query I'm using:Code:-- -- Table structure for table `pms` -- CREATE TABLE IF NOT EXISTS `pms` ( `id` int(11) NOT NULL auto_increment, `parent` int(11) NOT NULL default '0', `user` int(11) NOT NULL, `time` timestamp NOT NULL default CURRENT_TIMESTAMP, `title` varchar(255) collate utf8_bin NOT NULL, `text` text collate utf8_bin NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=8 ; -- -------------------------------------------------------- -- -- Table structure for table `pm_recipients` -- CREATE TABLE IF NOT EXISTS `pm_recipients` ( `pm` int(11) NOT NULL, `user` int(11) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;Thanks in advance O:Code:SELECT `pms`.*, `recipients`.* FROM `pms`, ( SELECT `pm_recipients`.`pm`, `pm_recipients`.`user` AS `recipient` FROM `pm_recipients`,`pms` WHERE `pm_recipients`.`pm` = `pms`.`id` AND `pm_recipients`.`user` = '{$me->id}' ) AS `recipients` WHERE `pms`.`parent` = '0' GROUP BY `pms`.`id` ORDER BY `pms`.`time` DESC


Reply With Quote
Bookmarks