2015-11-09 410 views
0

我想在子查詢中使用子查詢返回的結果返回到另一個查詢的IN子句中我想做一些類似BULK COLLECT的工作,但是我猜測完全不像是在MySQL在查詢的IN子句中傳遞子查詢結果

可用於例如:

​​

我想存儲的ID此查詢返回,並用它在三個組設置OD delete語句,雖然我已經使用GROUP_CONCAT但它不是working

delete from applicationpackagefeature where featureid in (
    @features 
) 

回答

1

您可以在MySQL中使用Prepared Statements來實現此功能:

SET @query = CONCAT('delete from applicationpackagefeature where featureid in (
',@features,')'); 

PREPARE stmt FROM @query; EXECUTE stmt; DEALLOCATE PREPARE stmt;