我有2个表:publications
和books.
目前,表publications
为空。
我需要选择“书籍”表中卷“26”的所有书籍并将其插入出版物表格中。我还应该使用'thesorus'
填充列publications.component
我尝试了下面的sql,但似乎不正确:
INSERT INTO publications (book_fk, component) VALUES (SELECT book_id FROM books WHERE volume = 26, "thesorus");
任何建议都表示赞赏
答案 0 :(得分:3)
正确的语法是:
INSERT INTO publications (book_fk, component) SELECT book_id, 'thesorus' FROM books WHERE volume = 26
答案 1 :(得分:1)
INSERT INTO publications (book_fk, component) SELECT book_id, 'thesorus' FROM books WHERE volume = 26;
答案 2 :(得分:0)
Insert into (field1,field2) select field1, field2 from table1