我想在mysql v 3.23中编写这个sql select语句
select *
from radacct
where username in (
select username
from radcheck
where Attribute = 'max-weekly-session'
);
但是说
ERROR 1064: You have an error in your SQL syntax near
'select username from radcheck where Attribute= 'max-weekly-session')'
at line 1
在mysql v 5中这没关系,但我怎样才能在v3.33中做到?
答案 0 :(得分:1)
试试这个:
select a.*
from radacct a
join radcheck b on a.username = b.username
where b.Attribute = 'max-weekly-session'
答案 1 :(得分:1)
符合完全标准的子查询was added in 4.1支持。在此之前,您必须使用JOIN和其他解决方法来实现相同的效果。
请参阅12.2.8.11. Rewriting Subqueries as Joins for Earlier MySQL Versions
答案 2 :(得分:0)
select *
from radacct ra
inner join radcheck on ra.username = rc.username
where rc.Attribute = 'max-weekly-session'
答案 3 :(得分:0)
嵌套选择在MySQL版本中不可用< 4.1
以下工作
select radacct.*
from radacct inner join radcheck on radacct.username = radcheck.username
where radcheck.Attribute= 'max-weekly-session'
答案 4 :(得分:0)
我需要类似的东西,但这里给出的所有解决方案都会导致从radacct返回多个条目的错误。我通过在radacct键上添加group by
来修复此问题。
select ra.*
from radacct ra
inner join radcheck rc on ra.username = rc.username
where rc.Attribute = 'max-weekly-session'
group by ra.Id