Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i update 1 field by using 3 tables?

Status
Not open for further replies.

rtdvoip

Programmer
Aug 29, 2003
27
US
hiya fellas,

Can anyone help me with this?

I need to get current costs into the customer_record table.
Three tables 1 - customer_record
2 - Services
3 - traffic

Customer_record has a unique pin:voip_id and current_bill
Services has: voip_id associated with multiple clar_pins
Traffic has: clar_pins with costs

I need to sum the cost in traffice with the pins,
associate that back to the services in order to link
the pins to the voip_id and update the current_bill field.

I have tried multiple ways but they all keep bombing.

Any ideas?
Thanks in advance,
rtdvoip
 
I used a temporary table to handle the problem.
so if you read this, when do temporary tables get
released?
 
When you issue the command DROP #MyTempTable or when the server is restarted

Thanks

J. Kusch
 
Please post your code, w/ the use of the temp table, so that we may see what was done. Their may be a way to complete your task w/out the use of Ttables.

Thanks

J. Kusch
 
Here is how I was able to resolve my situation.
Thanks for all the help.
-- code follows below--
create procedure bill_amount
as
create table #temp
(voip_id varchar(128),
amount money);

insert into #temp (voip_id,amount)
select voip_id,sum (call_cost)
from services,bt_test
where services.clarent_pin = bt_test.clarent_pin
group by voip_id

update customer_record
set current_bill_amount = customer_record.current_bill_amount + #temp.amount
from customer_record,#temp
where customer_record.voip_id = #temp.voip_id
go
--end code--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top