RSS Forums RSS
Please support our MS SQL advertiser: Programming Forums

INSERT table data depending on other table data

Join Date: Jul 2007
Posts: 3
Reputation: goodtimeshaxor is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
goodtimeshaxor goodtimeshaxor is offline Offline
Newbie Poster

INSERT table data depending on other table data

  #1  
Jul 29th, 2007
Hello. I'll get to the point. I need to add new rows to table2 depending on the data found in table1. I've tried a small query I wrote up myself but I doubt it will work and can't risk screwing this database up. Note: These tables are extremely long, one of them has over 300,000 records but only about 50 lines need to be added.

Here is the structure:

Table: user_data
Selected Columns: user_id, round_number, item_a, item_b, item_c

Table: user_item
Selected Columns: item_id(auto numbered), user_id, item_type, amount

Both tables have 'user_id' in common.

I need to get the values from 'item_a', 'item_b', and 'item_c'
FROM user_data
WHERE round_number = 89

and INSERT INTO user_item the sum of (item_a * 3 + item_b * 5 + item_c * 10)
The sum of these 3 operations should be inserted into user_item.amount

user_item.item_type should always be set to '5575'

(Also, a nice site of tutorials for MSSQL where I could learn would be nice as well)

Thank you
Last edited by goodtimeshaxor : Jul 29th, 2007 at 2:27 pm.
AddThis Social Bookmark Button
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 6:34 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC