从condition子查询获取错误的位置中选择Details

时间:2015-04-01 12:36:46

标签: sql

我有两张桌子。 APP_REVIEWREPLAY,APP_USERREVIEW。我在不同的表中使用子查询的条件,因为子查询返回双值,所以我得到错误。我的错误是

Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

select * from APP_REVIEWREPLAY where RID=(select RID from APP_USERREVIEW where HALLID=7095) 

2 个答案:

答案 0 :(得分:2)

使用连接

select r.* 
from APP_REVIEWREPLAY r
JOIN APP_USERREVIEW u on u.rid = r.rid
where u.HALLID=7095

in子句

select * 
from APP_REVIEWREPLAY 
where RID in (select RID from APP_USERREVIEW where HALLID=7095)

答案 1 :(得分:0)

尝试使用IN子句

select * 
from APP_REVIEWREPLAY 
where RID IN (select RID from APP_USERREVIEW where HALLID=7095)