在 iPad 应用程序上的 SQLite 中复制行

发布于 2024-11-01 22:09:09 字数 512 浏览 0 评论 0原文

我希望将一行从一个相同的表复制到 SQLite 中的另一个表。这是我的查询:

INSERT INTO savedarticles (headline, author, authorid, lead, contents, section, added, updated, dturl, storyid, pubDate, slot)
SELECT (headline, author, authorid, lead, contents, section, added, updated, dturl, storyid, pubDate, slot)
FROM articles
WHERE articles.storyid = '14556068'

这是 SQLite 给我的错误消息。

DB Error: 1 "near ",": syntax error"

我会复制一行错误吗?我更愿意使用 sql 进行 100% 复制,而不是创建对象并执行插入。

谢谢!

I am looking to copy a single row from one identical table to another in SQLite. Here is my query:

INSERT INTO savedarticles (headline, author, authorid, lead, contents, section, added, updated, dturl, storyid, pubDate, slot)
SELECT (headline, author, authorid, lead, contents, section, added, updated, dturl, storyid, pubDate, slot)
FROM articles
WHERE articles.storyid = '14556068'

And here is the error message SQLite is giving me.

DB Error: 1 "near ",": syntax error"

Am I going about copying a row all wrong? I would prefer to do the copy 100% with sql instead of creating an object and doing an insert.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不寐倦长更 2024-11-08 22:09:09

你不需要在 SELECT 上使用括号:

INSERT ...
SELECT headline, author, authorid, lead, contents, section, added, updated, dturl, storyid, pubDate, slot
FROM ...

并且你不需要引用 14556068,除非它确实是一个字符串:

WHERE articles.storyid = 14556068

SQLite 中的一切都是字符串,所以它不会在意,但好习惯就是好习惯。

You don't need parentheses on the SELECT:

INSERT ...
SELECT headline, author, authorid, lead, contents, section, added, updated, dturl, storyid, pubDate, slot
FROM ...

And you don't need to quote the 14556068 unless it really is a string:

WHERE articles.storyid = 14556068

Everything is a string in SQLite so it won't care but good habits are good habits.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文