select
uid
,CASE WHEN HOUR(subscribe_time) BETWEEN 0 AND 1 THEN '00:00:00'
WHEN HOUR(subscribe_time) BETWEEN 2 AND 3 THEN '02:00:00'
...
ELSE '23:00:00' END -- 生成时间分层部分,insert前外层sql加上日期后作为唯一的时间值
,COUNT(*)
FROM yht_fans WHERE subscribe_time>=UNIX_TIMESTAMP(CURDATE()) and subscribe_time<=UNIX_TIMESTAMP(CURDATE())+86400
GROUP BY 1,2
SELECT * FROM NODEWHERE PREV_NODE_ID NOT IN (SELECT DISTINCT NODE_ID FROM NODE)
AND PRNT_NODE_ID NOT IN (SELECT DISTINCT NODE_ID FROM NODE)
将 SELECT * 换成 DELETE 即可删除了
那就将语句改成下面这样
DELETE FROM NODE A
WHERE A.PREV_NODE_ID NOT IN (SELECT DISTINCT B.NODE_ID FROM NODE B WHERE B.ID = A.ID)
AND A.PRNT_NODE_ID NOT IN (SELECT DISTINCT B.NODE_ID FROM NODE B WHERE B.ID = A.ID)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)