User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 401,561 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,472 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Views: 1157 | Replies: 0
Reply
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 1:27 pm.
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MS SQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the MS SQL Forum

All times are GMT -4. The time now is 3:48 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC