I can not glue these 2 requests
SELECT q.* FROM `subscribers` AS sub, `questions` AS q WHERE (sub.id = 1 AND q.to = sub.id_subscriber) ORDER BY `time` DESC LIMIT 20 SELECT d.* FROM `subscribers` AS sub, `discussion` AS d WHERE (sub.id = 1 AND d.to = sub.id_subscriber) ORDER BY `time` DESC LIMIT 20
Do so
( SELECT q.`id`, q.`text`, q.`reply`, q.`time`, q.`from`, q.`to`, q.`ip`, q.`is_anonum`, 'null' AS q.`question_id` FROM `subscribers` AS sub, `questions` AS q WHERE (sub.id = 1 AND q.to = sub.id_subscriber) ORDER BY `time` DESC LIMIT 20 )UNION ( SELECT d.`id`, d.`text`, d.`reply`, d.`time`, d.`from`, d.`to`, d.`ip`, d.`is_anonum`, 'null' AS d.`likes`, 'null' AS d.`discussion`, 'null' AS d.`salt` FROM `subscribers` AS sub, `discussion` AS d WHERE (sub.id = 1 AND d.to = sub.id_subscriber) ORDER BY `time` DESC LIMIT 20 ) ORDER BY `time` DESC
But they send me where to further, here’s a dump if that
CREATE TABLE `discussion` ( `id` int(11) NOT NULL auto_increment, `question_id` int(11) NOT NULL, `text` TEXT NOT NULL, -- Вопрос `reply` TEXT NOT NULL, `time` int(11) NOT NULL, `from` int(11) NOT NULL, `to` int(11) NOT NULL, `ip` varchar(25) NOT NULL default '', `is_anonum` TINYINT(1) NOT NULL, PRIMARY KEY (`id`) ) ENGINE = MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=cp1251; CREATE TABLE `questions` ( `id` int(11) NOT NULL auto_increment, `text` TEXT NOT NULL, `reply` TEXT NOT NULL, `time` int(11) NOT NULL, `likes` int(8) NOT NULL default '0', `discussion` int(8) NOT NULL default '0', `salt` char(3) NOT NULL default '', `from` int(11) NOT NULL, `to` int(11) NOT NULL, `ip` varchar(25) NOT NULL default '', `is_anonum` TINYINT(1) NOT NULL, PRIMARY KEY (`id`) ) ENGINE = MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=cp1251; CREATE TABLE `subscribers` ( `id` int(11) NOT NULL, -- id юзера `id_subscriber` int(11) NOT NULL, -- На кого подписан юзер `time` int(11) NOT NULL ) ENGINE = MyISAM DEFAULT CHARSET=cp1251;
0 as likes
) - alexlz