[thelist] SQL 2000 update statement

Paul Cowan evolt at funkwit.com
Mon Aug 12 21:28:01 CDT 2002


Ingrid Z wrote:
> Right now, I can put the order total in each row with that user name.
> Is there a way to update only ONE column that has the same 'LastName",
> instead of updating all ?
> Currently, am using this...
> Update ProdSummary Set TheTotalOrder = @total where LastName = @last
>
> I want to update only ONE row that has that LastName..

Well, that kind of depends. So you've got a table (ProdSummary) with
something like:
   TheTotalOrder   FirstName   LastName
   -------------   ---------   --------
   $151.90         Mary        Smith
   $75.20          Mary        Smith
   $11.10          Joe         Jones
   $58.95          Mary        Smith

yes?

And you want to update, say, the second row from $75.20 to $78.50? Is this
the kind of thing we're talking about?

To do this kind of thing, you really need more data in the table. What's
the primary key into the "Sales" table (or whatever)? Is there a "SalesID"
or something like that? As it stands, there's no real way of (reliably)
doing
this, unless there are other fields that uniquely identify a given sale.

Unless I've misinterpreted what you want, in which case, sorry.

Paul Cowan




More information about the thelist mailing list