gigantorTRON Posted August 28, 2007 Share Posted August 28, 2007 Hey guys! I'm a semi n00bie here and I am having a really hard time with this new project. What I'm needing to do is create a new table that pulls data in from existing legacy system tables. For example... I'm making a table like this one.. | InventoryID | InventoryDesc | InventoryType The data to populate this table has to come from other tables which are arranged in a hierarchical fashion. I can select InventoryID straight in from Table A. To get the inventory description though, I have to get an inventoryDescription ID from Table A and then use that to reference the description field of table B and UPDATE my table. Finally, to get an inventoryType I have to get the inventory description ID from table A, pull the inventoryType ID from table B and then use that result to pull the inventoryType text from table C to UPDATE the table. So it all looks something like this... * is columns I need to pull in. Table C: InventoryTypeID InventoryTypeDescr.* InventoryTypeCount Table B: InventoryDescID InventoryDescText* InventoryTypeID Table A: InventoryID* InventoryDescID InventoryCount Destination Table: InventoryID InventoryDescText InventoryTypeDescr I'm sure that this requires some sort of join which unfortunately I'm not too great with. Any help?? ??? Quote Link to comment https://forums.phpfreaks.com/topic/66998-joinnormalize-help/ Share on other sites More sharing options...
fenway Posted August 28, 2007 Share Posted August 28, 2007 Try this: insert into destinationTable ( InventoryID, InventoryDescText, InventoryTypeDescr ) select a.inventoryID, b.InventoryDescText, c.InventoryTypeDescr from tableA as a join tableB as b on ( a.InventoryDescID = b.InventoryDescID ) join tableC as c on ( c.InventoryTypeID = b.InventoryTypeID ) Quote Link to comment https://forums.phpfreaks.com/topic/66998-joinnormalize-help/#findComment-336130 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.