以下是返回语法错误问题。 在线搜索后,我看不出原因。有什么想法吗?
delete Tracks
from tracks
left join releases
on tracks.label_id=releases.label_id
where tracks.label_id = 185
and releases.id = 4394
and tracks.position = 1
and tracks.name != 'Da Antidote';
语法错误在第1行。
答案 0 :(得分:2)
如果我没记错,Postgres不允许在DELETE
中加入,但您可以使用USING
关键字代替described in the documentation:
DELETE FROM Tracks
USING releases
WHERE tracks.label_id=releases.label_id
AND tracks.label_id = 185
AND releases.id = 4394
AND tracks.position = 1
AND tracks.name != 'Da Antidote';
答案 1 :(得分:1)
delete from tracks
left join releases
on tracks.label_id=releases.label_id
where tracks.label_id = 185
and releases.id = 4394
and tracks.position = 1
and tracks.name != 'Da Antidote';
答案 2 :(得分:0)
您可以使用EXISTS条款:
DELETE FROM tracks t1 WHERE EXISTS (
SELECT 1 FROM releases t2 WHERE
t1.label_id = t2.label_id
AND yadda, yadda, yadda
);