开发者

Copy row in SQLite on iPad application

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, pubD开发者_如何学编程ate, 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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜