0

嗨,我有一个相当复杂的查询,我在 SQLite 中使用了很长时间。它是这样开始的:

delete FROM 
   verbal_sets 
WHERE verbal_sets.verbal_set_id IN( 
   SELECT 
       F.verbal_set_id 
   FROM verbal_sets AS F WHERE Exists( 
       SELECT 
         knowledge_id, phrase_id,first_entity_text, second_entity_text,verbal_relation_text, Count(verbal_set_id) 
       FROM
        (...)

我现在正在创建同一软件的 MySQL 支持版本,但 MySQl 不喜欢这个查询。它返回错误:

[Err] 1093 - You can't specify target table 'verbal_sets' for update in FROM clause

我对 MySQL 的细节没有经验。谁能指出我必须用这个查询做什么?

4

2 回答 2

0

我希望这能帮到您,

delete FROM 
   verbal_sets 
WHERE verbal_set_id IN( 
   SELECT * 
    From( 
       SELECT knowledge_id, 
              phrase_id,
              first_entity_text, 
              second_entity_text, 
              verbal_relation_text, 
              Count(verbal_set_id) 
       FROM  verbal_sets
       ) as c
)
于 2016-06-04T11:23:30.550 回答
-1

只需跳过几行:

DELETE FROM 
   verbal_sets 
WHERE Exists( 
       SELECT 
         knowledge_id, phrase_id,first_entity_text, second_entity_text,verbal_relation_text, Count(verbal_set_id) 
       FROM
于 2012-07-17T22:24:02.333 回答