简体   繁体   English

如何在 SQL/phpmyadmin 中执行此操作?

[英]How can I do this in SQL/phpmyadmin?

I made tables:我做了表:

books - with columns ID_Books and Name_Books书籍 - 具有ID_BooksName_Books

authors - ID_Authors and Name_Author作者 - ID_AuthorsName_Author

product - ID and Author and Book产品 - IDAuthorBook

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如果ID_BooksID_Authors相同,我需要将其放入产品中,然后将该 ID 放入ID中,在Author中放入具有相应 ID 的Name_Author ,在Book中放入带有相应 ID 的Name_Books

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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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