On 15-Mar-2003 Mr Orange wrote:
> Hello all : )
> 
> Can anyone offer any advice on how to achieve the following with SQL?
> 
> Say I have a table.....
> 
> CREATE TABLE page (
>   pgposition int(6) not null,
>   pgelement char(20) not null default '',
>   pgsize int(4) not null default '0'));
> 
> and it has this data in.....
> 
>   1,"TEXT",20
>   2,"TEXT",30
>   3,"PASSWORD",10
> 
> How do I get 2 and 3 to change over, so the data becomes.....
> 
>   1,"TEXT",20
>   2,"PASSWORD",10
>   3,"TEXT",30
> 
> Thanks in advance,
> Steve.
> 
> 

Untested:

UPDATE page 
  SET pgposition=IF(pgposition=3, 2, 3)
  WHERE pgposition IN (2,3);

Regards,
-- 
Don Read                                       [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.
                            (53kr33t w0rdz: sql table query)

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to