mysql 私信分组问题

dreamhack 发布于 2016/04/02 01:54
阅读 392
收藏 0

睡前来一贴。

CREATE TABLE `site_mail` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `parent_id` bigint(20) unsigned NOT NULL DEFAULT '0',
  `mail_id` bigint(20) unsigned NOT NULL DEFAULT '0',
  `send_uid` bigint(20) unsigned NOT NULL DEFAULT '0',
  `accept_uid` bigint(20) unsigned NOT NULL DEFAULT '0',
  `content` varchar(500) NOT NULL DEFAULT '0' COMMENT '站邮内容',
  `send_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '发送时间',
  `read` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `su_status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '发送方状态',
  `au_status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '接受方状态',
  `status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '1正常,0删除',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_mail_id` (`mail_id`) USING BTREE,
  KEY `mail` (`send_uid`,`accept_uid`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=49 DEFAULT CHARSET=utf8 COMMENT='站邮表'


这是一个网站的私信表,在分组的时候数据有重复。


我的sql是:


SELECT A.mail_id,A.content,A.send_uid,A.accept_uid,A.send_time,A.`read`,B.uid,B.`name`,B.avatar
                FROM site_mail A inner join user B on A.send_uid=B.uid
                where (A.send_uid=386 AND su_status=1) OR (A.accept_uid=386 AND au_status=1)
                AND A.status=1 group by A.send_uid order by A.send_time;

求个sql啊



加载中
返回顶部
顶部