使用内部联接删除查询不起作用

Shr*_*asD 2 sql

遇到简单查询问题:

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);
Run Code Online (Sandbox Code Playgroud)

我在内部遇到语法错误,我不知道为什么.当我使用选择变体时它工作正常.

Mic*_*son 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
  );
Run Code Online (Sandbox Code Playgroud)

请注意,别名mv是在delete和之间添加的from.

这表明哪个表应删除了记录...您还可以选择使用删除其他表中的记录delete c from.