Reputation: 789
I have a table with more than 7000 book inserted, however I need to create another table for Gibis and Files, to have control of all the inserts I have a generic table called collection.
It follows the structures:
Collection:
CREATE TABLE collection(
collectionCod INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
collectionType VARCHAR(50) NOT NULL,
collectionTitle VARCHAR(100),
collectionImg VARCHAR(100),
collectionInfo INT)
Book:
CREATE TABLE book(
bookInfo INT PRIMARY KEY,
bookSubject VARCHAR(100),
bookTitle VARCHAR(100),
bookAuthor VARCHAR(100))
I need to generate an insertion in the collection for each existing book, as I do in SQL? Putting the type as book.
Upvotes: 0
Views: 24
Reputation: 1269563
Something like this:
insert into collection (collectionTipy, collectionTitle, collectionImg, collectionInfo)
select bookSubject, bookTitle, NULL, bookAuthor
from book;
I don't know what the exact mapping is between the fields in the book
and collection
, but this is the idea.
Upvotes: 1