Click here to Skip to main content
15,902,842 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi,
i required some help from you....


i have 2 tables,

1.usertable with columns (userid,username,usertype)

here we can give usertype=employee or customer,if it is employee in uerdetails table i need to update emp count = 1,
include with this i need to update this records to all previous registered user records...like a chain system

2.userdetails table with columns(userid,userscount,emp.count,cust.count)


here,main thing is if iam a new registered user,then all particular counts should be updated to previous registered users.
Posted
Updated 21-Dec-11 18:43pm
v2

If I understood correctly, you would like to update calculated information in some table based on other tables. If that's the case I suggest you don't do that. Storing calculation (such as count, multiplications etc) results in the the database will typically lead to problems.

Instead do the calculations when you fetch the data. This way you always get the right results and you have less SQL statements to execute in insert/update phase.
 
Share this answer
 
Comments
thatraja 22-Dec-11 14:54pm    
Storing calculation (such as count, multiplications etc) results in the the database will typically lead to problems
Ofcourse I agree. Nice suggestion, 5!
Wendelius 22-Dec-11 15:00pm    
Thanks, actually I wasn't unconditional since there are cases when this makes sense, especially reporting environments. After all, thats one reason for ELT process :)
 
Share this answer
 
v2
Comments
thatraja 22-Dec-11 14:56pm    
Yep, He need row by row operation so he must go with cursor or while loop or any other alternatives, 5!
Monjurul Habib 22-Dec-11 14:59pm    
thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900