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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OK... A better way of handeling SQL Updates

Status
Not open for further replies.

pingLeeQuan

Programmer
Jul 3, 2002
45
US
Sorry if this post needs to be in the sql group.

I am trying to update bunch of records in the same table with a value from one of those records.

I have n records of which i have x that have blank ssnumber.
These x records belong to multiple categories.

I need to be able to update group x records category "A" with values from x records (there should be a record in each group that has a valid value to populate the others)

And the same applies for the other categories.

I can select * from table order by category and then the value. Then i can have a loop to pick and update each one. I do not think this is efficient.

Is there a better way to handle this? I started brain storming but i could not glow it together.

I user a select * from ... order by category, value DESC
then I used filtering
then I used update... that’s when I lost it.

If I use Group by on filtering to update a whole bunch of records per category.... would this work... how?


Thanks in advance..
Quan
 
See if this article helps:


James P. Cottingham

When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity.
[tab][tab]Albert Einstein explaining his Theory of Relativity to a group of journalists.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top