Query help
Fajar A. Nugraha
list at fajar.net
Mon Oct 15 02:40:01 CEST 2012
On Mon, Oct 15, 2012 at 7:35 AM, Fajar A. Nugraha <list at fajar.net> wrote:
> If yes, it should be MUCH quicker to simply do the comparison INSIDE
> the sql statement. Something like (untested, should work for mysql):
>
> if ("%{sql: ( (SELECT radgroupcheck.value FROM radusergroup Inner Join
> radgroupcheck ON radusergroup.groupname = radgroupcheck.groupname
> WHERE radusergroup.username = '%{User-Name}' AND
> radgroupcheck.attribute = 'CS-Total-Octets-Monthly' LIMIT 1) <=
> (SELECT SUM( AcctInputOctets + AcctOutputOctets) FROM radacct WHERE
> UserName='%{User-Name}' AND AcctStartTime >
> (DATE_SUB(CURDATE(),INTERVAL DAYOFMONTH(CURDATE())DAY))) ) as
> overlimit" } == 1 ){
Sorry, it should be something like
if ("%{sql: SELECT ( ( SELECT your_limit_query ) <= ( SELECT
your_acct_query ) ) as overlimit;"} == 1 )
My first example is (obviously) missing the first select, but you get
the idea :)
--
Fajar
More information about the Freeradius-Users
mailing list