遇到简单查询问题:
DELETE FROM t_meter_value mv
INNER JOIN t_channel c ON mv.t_channel_id = c.id
WHERE (c.t_device_device_address = 16777216 OR
c.t_device_device_address = 33619968)
AND c.t_channelspec_channel_address NOT IN
(256, 257, 259, 263, 261, 326, 271, 281, 273, 32778);
我在内部遇到语法错误,我不知道为什么。当我使用select变体时,它可以正常工作。
答案 0 :(得分:5)
相反,请尝试:
delete mv from t_meter_value mv
inner join t_channel c on mv.t_channel_id = c.id
where (
c.t_device_device_address = 16777216 or
c.t_device_device_address = 33619968
) and
c.t_channelspec_channel_address not in (
256, 257, 259, 263, 261, 326, 271, 281, 273, 32778
);
请注意,mv
和delete
之间添加了别名from
。
这表示哪个表应删除了记录...您还可以选择使用delete c from
从其他表中删除记录。