我正在尝试通过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')
但它返回相同的语法错误。
答案 0 :(得分:1)
请勿使用双引号,而应使用2个单引号''
,过滤条件要求将值括在单引号中。
验证代码始终是一个好习惯,您可以使用Print @sql
EX:
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')