SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    whats wrong with this select statement

    hello,
    whats wrong with the select case statement below ?

    rgds
    afrika
    Code:
    select @results = 
    case when receipient like '234804%' or receipient like '1%' or receipient like '44%'
    then 
    update sms_credits set credits = (@total_credits -  1.5) where username = @user
    else 
    update sms_credits set credits = (@total_credits -  1) where username = @user
    end
    from inserted

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,220
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    what's wrong is that you cannot execute an UPDATE statement nested inside a SELECT
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey Rudy,
    thanks a lot, i didnt realize that

    rgds
    Afrika


Bookmarks

Posting Permissions

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