Please support our MS SQL advertiser: Programming Forums
Views: 1308 | Replies: 0
•
•
Join Date: Jul 2007
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
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
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.
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)






Threaded Mode