Is there a query where I could match if field cmd has been sent more then 3 times with the same content in the last 15 minutes ?
I currently have this:
SELECT COUNT(*)
FROM `log`
WHERE gid = @gid
AND ts_register BETWEEN DATE_SUB(NOW() , INTERVAL 15 MINUTE) AND NOW()
Which will gather me all the messages sent in the last 15 minutes by the global id.
Is there a way to take the field cmd into consideration and list if the gid has sent a repeated cmd more then 3 times within the last 15 minutes ?
for example:
gid 1 cmd testing repeatable cmd
gid 1 cmd testing repeatable cmd
gid 1 cmd testing repeatable cmd
gid 1 cmd different cmd
So it would give me the count of 3.
You want to do this:
Given your data, that would return:
Update
Using @Gidon’s suggestion (Upvoted you, man!), you can add a
HAVINGclause to display only the ones with more than 3: