Jump to content
Sign in to follow this  

Script help - SQL get value

Recommended Posts

Hi All,

Hoping that someone can point me in the right direction for this one.

This is the current script:
SELECT LEFT(t.SUBJECT,250) AS `Ticket Subject` FROM tickets t JOIN computers c ON c.computerid=t.computerid WHERE c.computerid = '%computerid%' AND TIMEDIFF(t.starteddate, NOW()) <  '72:00:00' AND NOT t.subject LIKE 'LTVM Guest%' AND NOT t.subject LIKE '%success%' GROUP BY `Ticket Subject` HAVING COUNT(*) > '350'

This script was setup by the old admin that is no longer with the company. I was having a look into it because it seemed to be logging false positives and found that the section <TIMEDIFF(t.starteddate, NOW())> is actually finding a negative value so it wasn't working as intended. 

I updated it to <TIMEDIFF(NOW(), t.starteddate) <  '72:00:00'> and that broke the script.
I also tried <TIMEDIFF(t.starteddate, NOW()) >  '-72:00:00> and <starteddate > DATE_SUB(NOW(), INTERVAL 72 HOUR)> but the script is still failing at that line. 

All 3 options above run correctly when running them against the DB myself so im at a loss to why they are failing in the script. 

I attempted to simplify it by changing the whole script to this:
SELECT LEFT(`subject`,250) AS `Ticket Subject` FROM tickets WHERE computerid = '
%computerid%' AND starteddate > DATE_SUB(NOW(), INTERVAL 72 HOUR) AND NOT `subject` LIKE 'LTVM Guest%' AND NOT `subject` LIKE '%success%' GROUP BY `Ticket Subject` HAVING COUNT(*) > '350'
But that also failed in the script despite working in mysql. 

Has anyone had this happen before? Any ideas where I am going wrong?

edit: if it matters, still on v11 patch 19.

Any help is appreciated.


Edited by Axle

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this