SQL CASE statement for UPDATE


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: SQL CASE statement for UPDATE

  1. #1
    David Satz Guest

    Re: SQL CASE statement for UPDATE

    not sure I understand your diagram, but you use CASE when an UPDATE in the
    same way as you do w/a select
    --
    HTH,
    David Satz
    Principal Web Engineer
    Hyperion Solutions
    { SQL Server 2000 SP2/6.5 SP5a } { Cold Fusion 5 SP1 } { VSS }
    (Please reply to group only - emails answered rarely)
    -----------------------------------------------------------------
    "james" <cowlibob@hotmail.com> wrote in message
    news:3d1c8242$1@10.1.10.29...
    >
    > Ladies and Gentlemen,
    > I've seen the SELECT CASE... statement, but wonder if there is a similar
    > construct for the UPDATE?
    >
    > I'm trying to update one of two columns, based on the value of a third.

    eg.
    >
    > here, I would like col1 to be updated
    > +------+------+------+
    > | col1 | col2 | col3 |
    > +------+------+------+
    > | 1 | 5 | col1 |
    > +------+------+------+
    >
    > and here, I would like col2 to be updated
    > +------+------+------+
    > | col1 | col2 | col3 |
    > +------+------+------+
    > | 1 | 5 | col3 |
    > +------+------+------+
    >
    > Is this possible in a single update statement?
    >
    > Thanks,
    > James.




  2. #2
    james Guest

    SQL CASE statement for UPDATE


    Ladies and Gentlemen,
    I've seen the SELECT CASE... statement, but wonder if there is a similar
    construct for the UPDATE?

    I'm trying to update one of two columns, based on the value of a third. eg.

    here, I would like col1 to be updated
    +------+------+------+
    | col1 | col2 | col3 |
    +------+------+------+
    | 1 | 5 | col1 |
    +------+------+------+

    and here, I would like col2 to be updated
    +------+------+------+
    | col1 | col2 | col3 |
    +------+------+------+
    | 1 | 5 | col3 |
    +------+------+------+

    Is this possible in a single update statement?

    Thanks,
    James.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center