Код: Выделить всё
SELECT *
FROM `messages`
WHERE `sub_cat_id` = '17'
AND `visible` = '1'
ORDER BY RAND( )
LIMIT 5
Код: Выделить всё
CREATE TABLE `messages` (
`id` int(6) NOT NULL auto_increment,
`visible` int(1) NOT NULL,
`sub_cat_id` int(3) NOT NULL,
`add_date` int(15) NOT NULL,
`ip` varchar(15) NOT NULL,
`msg_zag` varchar(255) NOT NULL,
`msg_text` text NOT NULL,
`city` int(3) NOT NULL,
`price` varchar(32) NOT NULL,
`person` varchar(70) NOT NULL,
`org` varchar(70) NOT NULL,
`phones` varchar(70) NOT NULL,
`site` varchar(127) NOT NULL,
`email` varchar(64) NOT NULL,
`spamprotect` int(1) NOT NULL,
`image` varchar(9) NOT NULL,
PRIMARY KEY (`id`),
KEY `visible` (`visible`),
KEY `sub_cat_id` (`sub_cat_id`),
KEY `add_date` (`add_date`),
KEY `city` (`city`)
) ENGINE=MyISAM AUTO_INCREMENT=15699 DEFAULT CHARSET=cp1251 COMMENT='таблица объявлений'
запрос выполянется 0.5-0.8 секунды =(
========
идеи есть?