Results 1 to 2 of 2

Thread: update SQL

  1. #1
    Join Date
    Dec 2003
    Location
    USA
    Posts
    33

    Unanswered: update SQL

    hi,

    User
    ----
    Usr_ID N 10
    Country_ID N 10
    Branch_id N 10
    Region_Code C 10
    User_name C 50
    User_add1 C 50
    User_add2 C 50
    User_add3 C 50
    Status C 1

    Country
    -------
    Country_ID N 10
    country_name C 40

    Branch
    ------
    Branch_ID N 10
    Branch_name C 40
    Country_ID N 10



    I have written the following query to update all
    user status to 1 for branch_id=1 and Region_code='AB'.

    Update user set Status=1 where User.Id=
    (select user.id from user,country,branch where branch.branch_id=1 and user.branch_id=branch.branch_id(+)
    and user.country_id=country.country_id(+)
    and (user.region_Code IN ('AB','BC' ))


    Now my problem is I have to also update Status to 1 in the same above SQL
    for Region_Code='DC', irrespective of the branch_id=1.

    Thanx in advance.

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Why did you not write the first update as:
    Code:
    update user
    set  status = 1 
    where branch_id=1 and Region_code='AB';
    (i.e. virtually the same as the stated requirement "update all user status to 1 for branch_id=1 and Region_code='AB'!)

    You second update would then be:
    Code:
    update user
    set  status = 1 
    where (branch_id=1 and Region_code='AB') or (Region_code='CD');

Posting Permissions

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