如:表中有ID为a,b,c,d,e的行,用一条SQL删除ID号为abc的行:
答:delete from 表名 where id in (a,b,c)
/usr/local/mysql3306/bin/mysql -uroot -p88888 -e "show full processlist" >>/root/temp.txt
MySQL 查询统计
-- SELECT * FROM test where `分数` in (SELECT `分数` FROM test GROUP BY `分数` HAVING COUNT(`分数`)>3)
-- 查询一周:
-- select * from table where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(column_time);
-- N天内记录
-- WHERE TO_DAYS(NOW()) - TO_DAYS(时间字段) <= N
以下是查询7天之内,访问目标表6次的统计记录列表
SELECT
*
FROM
wz_violationrequest
WHERE
`reqid` IN (
SELECT
`reqid`
FROM
wz_violationrequest
GROUP BY
`reqid`
HAVING
COUNT(`reqid`) >= 6
)
and createtime > '2017-03-10 17:33:00'
AND DATE_SUB(CURDATE(), INTERVAL 7 DAY)
==========================================
select count(*) from wz_violationrequest where CreateTime BETWEEN '2017-03-09 00:00:00' and '2017-03-10 00:00:00'
3月9日 一天,请求数量是 85325 条数据