Connecting Tech Pros Worldwide Forums | Help | Site Map

Update 3 rows at a time

equalive
Guest
 
Posts: n/a
#1: May 19 '06
Hi friends,

Can anyone guide me on this.

Just assume i have table name "Alphabet" and a field name "Name".

Inside the table contains:

Name
A(1st row)
B(2nd row)
C(3rd row)

and i wana update
A -> D
B -> E
C -> F

How is it possible to do using one single SQL?

I really appreciate your reply.

Thanks guys.


PBsoft
Guest
 
Posts: n/a
#2: May 19 '06

re: Update 3 rows at a time


> Just assume i have table name "Alphabet" and a field name "Name".[color=blue]
>
> Name
> A(1st row)
> B(2nd row)
> C(3rd row)
> and i wana update
> A -> D
> B -> E
> C -> F
> How is it possible to do using one single SQL?[/color]

UPDATE AlphaBet SET AlphaBet.Name = Chr(Asc([Name])+3)
WHERE (((AlphaBet.Name)="A")) OR (((AlphaBet.Name)="B")) OR (((AlphaBet.Name)="C"));

--
PBsoft di Gabriele Bertolucci
www.pbsoft.it
skype: pbsoftsolution


equalive
Guest
 
Posts: n/a
#3: May 19 '06

re: Update 3 rows at a time


Yes, its working fine with your coding, Thanks.

But how if it is not an alphabet or a word such as

Mouse -> Snake
Snake -> Eagle
Deer -> Tiger

Earlier i juzt use Alphabatical so that easy for the reader to
understand. Can you guide me on above situation if it is a word rather
than alphabet. Thanks again.

Terry Kreft
Guest
 
Posts: n/a
#4: May 19 '06

re: Update 3 rows at a time


SQL is all about sets.

In this situation where there is nothing to group the original values
together and nothing to describe the update you would have to use separate
updates for each line.

In your original example a rule could be created for the update, this is not
the case with this example.

The only way to get round this would be to create a "translation" table, in
this table you would define the original value and the target value you
could then use this to update your table. This really is only any use where
the values appear multiple times and would certainly not be suitable in a
case as trivial as the one you cite.


--

Terry Kreft


"equalive" <equalive@yahoo.com> wrote in message
news:1148029468.107239.12210@j73g2000cwa.googlegro ups.com...[color=blue]
> Yes, its working fine with your coding, Thanks.
>
> But how if it is not an alphabet or a word such as
>
> Mouse -> Snake
> Snake -> Eagle
> Deer -> Tiger
>
> Earlier i juzt use Alphabatical so that easy for the reader to
> understand. Can you guide me on above situation if it is a word rather
> than alphabet. Thanks again.
>[/color]


Closed Thread