将子查询结果传递给查询的IN子句

时间:2015-11-09 08:55:31

标签: mysql subquery

我想将子查询返回的结果用到mysql中另一个查询的IN子句中我想做的事情就像在Oracle数据库中做BULK COLLECT一样,但我猜想在mysql中没有这样的东西

例如:

set @features := (select group_concat(apf.featureid ) from 
applicationpackagefeature apf ,
feature f,
applicationpackage ap,
applicationpackageapplication apa,
application a
where f.id = apf.featureid
and apf.applicationPackageId = ap.id
and apa.applicationPackageId = ap.id
and apa.applicationId = a.id
and a.platform = 'b'
and a.version = 'a'
and a.name = 'c');

我想存储此查询返回的id并在三个set set od delete语句中使用它虽然我已经使用了group_concat但它不能正常工作

delete from applicationpackagefeature where featureid in (
    @features 
)

1 个答案:

答案 0 :(得分:1)

您可以使用MySQL中的Prepared Statements来实现此目的:

 [WARN] -  s.can.client.HttpClientConnection - Configured connecting timeout of 10 seconds expired, stopping