Answer the question
In order to leave comments, you need to log in
How to select data from different tables?
Hi all!
There is such a query in mySQL:
select DISTINCT(COUNT(t1.username))
from radpostauth t1
where exists
(select *
from radacct t2
where `nasipaddress` = '146.120.17.42' AND t1.authdate between t2.acctstarttime and t2.acctstoptime
) AND `reply` = 'Access-Accept' AND `authdate` BETWEEN DATE_SUB(NOW(), INTERVAL 1 MONTH) AND NOW();
Answer the question
In order to leave comments, you need to log in
SELECT t1.radacctid
, t1.username
, t1.acctstarttime
, t1.acctstoptime
, t1.framedipaddress
, COUNT(*) as cnt
FROM radpostauth t1
WHERE exists (
SELECT *
FROM radacct t2
WHERE
`nasipaddress` = '146.120.17.42'
AND t1.authdate between t2.acctstarttime AND t2.acctstoptime
)
AND `reply` = 'Access-Accept'
AND `authdate` BETWEEN DATE_SUB(NOW(), INTERVAL 1 MONTH) AND NOW()
GROUP BY t1.`username` -- это важно
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question