Jump to content

Archived

This topic is now archived and is closed to further replies.

VTS

Inserting data from two places into a single table

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?

Share this post


Link to post
Share on other sites
I am not sure what you mean, but could something like [code]SELECT * FROM table1 AS t1 LEFT JOIN table2 AS t2 ON t1.department_id=t2.department_id[/code] do it?

Share this post


Link to post
Share on other sites
I think he means he needs to 'INSERT' data from multiple sources. Is that correct?  ???

Share this post


Link to post
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!!

Share this post


Link to post
Share on other sites

×

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.