Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2008
    Posts
    94

    Unanswered: how can i update this within a single statement?

    how to update a table based on multiple single column values.

    IF COLUMN1='P' THEN update stats COLUMN2 AS 'W' Else update COLUMN2 AS 'S';

    how can i update this within a single statement?

  2. #2
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    ..... based on multiple single column values.
    I couldn't understand well this clause.

    IF COLUMN1='P' THEN update stats COLUMN2 AS 'W' Else update COLUMN2 AS 'S';
    This would be the following statement.
    Code:
    UPDATE .....
       SET column2
           = CASE column1
             WHEN 'P' THEN
                  'W'
             ELSE 'S'
             END
     WHERE .....
    ;

  3. #3
    Join Date
    Jul 2008
    Posts
    94
    many thanks it worked for me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •