2012-05-14 65 views
0

插入我有2個表:publicationsbooks.拷貝列和另一

目前,該表publications是空的。

我需要選擇'書籍'表中的卷「26」的所有書籍,並將其插入到出版物表格中。我還要填充柱publications.component與「thesorus」

我想下面的SQL,但它似乎並不正確:

INSERT INTO publications (book_fk, component) VALUES (SELECT book_id FROM books WHERE volume = 26, "thesorus"); 

任何建議最欣賞

回答

3

正確的語法是:

INSERT INTO publications (book_fk, component) SELECT book_id, 'thesorus' FROM books WHERE volume = 26 
1
INSERT INTO publications (book_fk, component) SELECT book_id, 'thesorus' FROM books WHERE volume = 26; 
+0

thanks..it's great great – Kim

+0

Darhazer是第一個;) – triclosan

0
Insert into (field1,field2) select field1, field2 from table1