0

I have 2 tables: publications and books.

Currently, the table publications is empty.

I need to select all the books in the 'books' table with volume "26" and insert it in the publications table. I should also populate the column publications.component with 'thesorus'

I tried the sql below but it does not seem correct:

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

Any suggestion is most appreciated

3 Answers 3

3

The correct syntax is:

INSERT INTO publications (book_fk, component) SELECT book_id, 'thesorus' FROM books WHERE volume = 26 
Sign up to request clarification or add additional context in comments.

Comments

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

Comments

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.