Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mysql query with perl

Status
Not open for further replies.

reefbum

Technical User
Oct 30, 2006
3
US
I'm very new to perl and am in need of a bit of help with a perl script that is doing query to mysql DB for radius. Currently the script is doing a sum of octects from DB by username only. My issue is that it is doing the sum for ALL entries from that username. What i need it to do is sum all database entries by username for the current date only. So that database entries for previous days are not included in the sum.

This is the portion of the script in question.



$cursor = $dbh->prepare("SELECT SUM(AcctInputOctets), SUM(AcctOutputOctets), SUM(AcctSessionTime)
FROM radacct
WHERE username='$ARGV[0]'")
or die("Couldn't prepare");
$cursor->execute;


Thanks for any help you can offer
 
It sounds like you need MySQL help, not perl help. The sql forum is here:


You should let them know what your schema is. They at least need to know what the name of the date-like field in "radacct" is, and preferable what type it is. DATETIME, TIMESTAMP, DATE, or some other custom datatype?

All you'll need though is the CURDATE() function:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top