CREATE TABLE IF NOT EXISTS `ugroup_list` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`uid` int(11) NOT NULL,
`lider` int(11) NOT NULL,
`time` int(11) NOT NULL,
`type` varchar(300) NOT NULL,
`group` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
<?
SELECT
`users`.`time` ,
`users`.`id` AS `user_id` ,
`ugroup_list`.`uid` ,
`ugroup_list`.`lider` ,
`ugroup_list`.`type` ,
`ugroup_list`.`group`
FROM
`ugroup_list`
RIGHT JOIN `users` ON `ugroup_list`.`uid` = `users`.`id`
WHERE
`users`.`time` > '".(time() - 300)."'
AND
(
`ugroup_list`.`uid` IS NULL
OR
`ugroup_list`.`lider` != '".$lider['id']."'
AND
`ugroup_list`.`type` = 'operation-insert'
AND
`ugroup_list`.`group` = '0'
)
?>
SELECT
`users`.`id` AS `user_id` ,
`utime`.`uid` ,
`utime`.`type`
FROM `users`
LEFT JOIN `utime` ON `users`.`id` = `utime`.`uid`
WHERE `utime`.`type` is NULL
ORDER BY `user_id` ASC
LIMIT 0 , 6