简体   繁体   中英

How can I do this in SQL/phpmyadmin?

I made tables:

books - with columns ID_Books and Name_Books

authors - ID_Authors and Name_Author

product - ID and Author and Book

I need it to put in product if ID_Books and ID_Authors is same then put that id into ID and in Author put Name_Author with corresponding id and in Book put Name_Books with corresponding id

If I got your question right, you can perform a join and add that result into the third table.

INSERT INTO PRODUCT(ID,Author,Book) 
SELECT Id_Author, Name_Author, Name_Books 
FROM AUTHOR INNER JOIN BOOKS ON Id_Author = Id_Books;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM