Jump to content

Select then Insert into another table


CBG

Recommended Posts

Hi,

 

I would like to do the following in PHP using a MySQL database, but not sure how.

 

select a, b,c etc.. from mailbox where id = X

then

insert id,a,b,c etc.. into problem

 

When I select, I will be calling the id

 

So I would like it to get data from mailbox and then insert it into problem.

How would I go about doing this?

 

Thanks for any help you can give me :)

Link to comment
https://forums.phpfreaks.com/topic/233057-select-then-insert-into-another-table/
Share on other sites

Try having a read about subqueries or derived tables as they are sometimes know.

 

Something like this should work


INSERT INTO tblTABLE SET (Field1, Field2)
VALUES (SELECT Field1, Field2 FROM tblTABLE2)

 

It's a very simplified example but the logic should work.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.