medj Posted August 1, 2008 Share Posted August 1, 2008 I have 2 tables called 'components' and 'bom'. My 'components' table has 10 columns. (~100 rows) My 'bom' has 6 columns. (~12 rows) There is one column in the 'bom' table that has same value as one of the columns in the 'components' table. I would like to match this 'bom' column against the component column. I do know how to do this already with a query such as the following: SELECT `components`.`part_num`, `components`.`name` FROM `components` WHERE `components`.`part_num` IN (SELECT `bom`.`number` FROM `bom`) This is my problem that I am facing: I would like to be able to display all column data on the page. For example, I have 10 + 6 = 16 columns of data from both tables. I would like to display all the data from both tables. I already know the php code to display data from rows. For instance, I am able to display the 'part_num' and 'name' of all the components table for the 12 rows of the 'bom'. I can add more of these if I wanted to show the 10 rows from the components table. The main problem is that I would like to display the other 6 columns of data from the 'bom' table and I have tried many different alternations of the query but can't seem to make it work. Any help please? Quote Link to comment Share on other sites More sharing options...
fenway Posted August 5, 2008 Share Posted August 5, 2008 You need to JOIN these tables... SELECT c.*, b.* FROM components AS c INNER JOIN bom AS b ON ( b.number = c.part_num ) Quote Link to comment 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.