求优化一条SQL语句,在线等SQL初学者,对优化语句不知道用什么思路去写,求优化一条SQL语句:select * from sy
求优化一条SQL语句,在线等 SQL初学者,对优化语句不知道用什么思路去写,求优化一条SQL语句: select * from sys_family where fcid=774 and FserIsO=1 and fstuid not in(select c.CpersonId from sys_chit as c where c.ccid=774 and c.Csendtime between '2013-12-16 0:0:0' and '2013-12-16 23:59:59' GROUP BY c.CpersonId having count(c.CpersonId)>=5)
坐等高手帮忙优化,顺带说一下思路。 [解决办法]
1、把*换成字段名 2、not in 换成内连接 [解决办法] select * from sys_family A where A.fcid=774 and A.FserIsO=1 and not exists (select 1 from sys_chit as c where c.ccid=774 and c.Csendtime between '2013-12-16 0:0:0' and '2013-12-16 23:59:59' GROUP BY c.CpersonId having count(c.CpersonId)>=5 and C.CpersonId = A.fstuid) 如果可以送分哦!