954,593 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

INSERT table data depending on other table data

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

goodtimeshaxor
Newbie Poster
3 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You