0

我正在尝试按照来自 Adminer 4.6.2 的查询运行他,它给了我一个模糊的“语法错误”,没有进一步的细节:

 db_query("DELETE FROM {field_collection_item} WHERE field_name NOT IN (SELECT field_name FROM {field_config} WHERE type = 'field_collection')");

我也试过这个:

DELETE FROM {field_collection_item} WHERE field_name NOT IN (SELECT field_name FROM {field_config} WHERE type = 'field_collection')

但它返回相同的语法错误。

4

1 回答 1

1

不要使用双引号,使用2个单引号'',过滤条件要求值用单引号括起来。验证您的代码始终是一个好习惯,您可以使用 Print @sql 来做到这一点

前任:

DECLARE @sql VARCHAR(max)

SET @sql = 'DELETE FROM [field_collection_item] WHERE field_name
               NOT IN (SELECT field_name FROM [field_config] WHERE type = ''field_collection'')'

PRINT @sql

印刷:

    DELETE FROM [field_collection_item] WHERE field_name NOT IN 
   (SELECT field_name FROM [field_config] WHERE type = 'field_collection')
于 2018-07-12T08:07:46.400 回答