scotchegg78 Posted March 28, 2008 Share Posted March 28, 2008 Hi I have ran a query thats taking forever! Do i need a join for this, Its INSERT INTO new_table (field1,field2,...fieldn) SELECT table_1.id,table_1.name,table_2.company FROM table_1,table_2; So simple I have a tabel I am inserting fields from two tables into. thanks Link to comment https://forums.phpfreaks.com/topic/98309-insert-into-table-from-two-tables-need-a-join/ Share on other sites More sharing options...
scotchegg78 Posted March 28, 2008 Author Share Posted March 28, 2008 Here is the new full code... does this look ok? Could it be better? Insert Into listing_content(listingID,listingName,registeredOwner,registeredManager,RoomNum,registeredCareCategory) SELECT listing.listingID,address.tempHomeName,address.temp_owner,address.temp_regmanager,address.temp_beds,address.temp_regcarecategory FROM listing LEFT JOIN address ON listing.addressID = address.addressID; Link to comment https://forums.phpfreaks.com/topic/98309-insert-into-table-from-two-tables-need-a-join/#findComment-503067 Share on other sites More sharing options...
mwasif Posted March 28, 2008 Share Posted March 28, 2008 Do you have index on listing.addressID and address.addressID? Link to comment https://forums.phpfreaks.com/topic/98309-insert-into-table-from-two-tables-need-a-join/#findComment-503100 Share on other sites More sharing options...
fenway Posted March 28, 2008 Share Posted March 28, 2008 And why the left join? Link to comment https://forums.phpfreaks.com/topic/98309-insert-into-table-from-two-tables-need-a-join/#findComment-503616 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.