【发布时间】:2019-03-18 18:20:50
【问题描述】:
我看过这两个帖子:
How delete table inner join with other table in Sqlite?
SQlite delete inner join
但我很确定这个问题不是重复的。
所以我写了这个选择语句:
select * from tags
inner join pictures
on pictures.id = tags.picture_id
inner join albums
on pictures.album_id = albums.id
where tags.user_id = 1 and pictures.name = "Me and Obama" and albums.name = "Me and VIPs";
现在我几乎需要从中创建一个删除语句。
我尝试用“delete”替换“select *”,但这不是正确的语法。
我该怎么做呢?这是我目前所拥有的:
delete from tags
where picture_id in (select id from pictures where name = "Me and Moshe Dayan") and tags.user_id = 1
但它缺少与专辑的整个内部连接,我不知道如何实现。
任何帮助将不胜感激!
【问题讨论】:
-
旁注:SQL 使用双引号来标记表和列名等标识符,并使用单引号标记字符串。如果没有与内容匹配的标识符,Sqlite 有时会将双引号视为字符串,但最好还是坚持标准并使用单引号:
'Me and Obama'等。