Jump to content

Inserting data from two places into a single table


VTS

Recommended Posts

I will try to lay this out the best that I can.  I have a table that has the date, sales, department id, operating hours, and operating wages. 

I am getting the date, sales and department id from one place and then I am getting the operating hours and operating wages from another department. 

The major problem that I am having is that the place where I am getting the hours and wages from has some departements that the sales won't have and then the sales will have some departments that the hours and wages wont....does this mean I just need to make another table to store sales in one and wages and hours in another?
Link to comment
Share on other sites

Well the problem was that one source will have wage data and the other source will have sales data and they will not always have the same departments.  For example, the wage data my contain departments 1, 2, 3, 4, and 5 while the sales data may contain departments 1, 2, 3, 6, and 7.  I was wondering how to go about inserting these into the datebase but I figured it out now.  I just made a new table containing all the the departments and their id numbers.  Then I used some sql and php to check and see what totals were missing and then if a total was missing, I just inserted zeroes into that row in the db.  After doing this, all of my departments were accounted for and then I could just use a simple update statement to put the sales data in.  Thanks for the posts guys!!

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.