Jump to content

Selecting from 2 tables


medj

Recommended Posts

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?

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.