Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9322691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T04:09:24+00:00 2026-06-19T04:09:24+00:00

It seems I have big problems with conditional queries . I have to do

  • 0

It seems I have big problems with conditional queries.

I have to do a conditional update. I write here what I would like to do:

 IF(SELECT tipo FROM abbonamento WHERE idU = 17) = 'punti' THEN
     UDPATE abbonamento SET punti = punti - 1 
 ELSE
     UPDATE abbonamento SET bonus = bonus - 1

Obviously this doesn’t work.
Any idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T04:09:25+00:00Added an answer on June 19, 2026 at 4:09 am

    MySQL supports IF statement.

    UPDATE  abbonamento
    SET     punti = IF(tipo = 'punti', punti - 1, punti),
            bonus = IF(tipo <> 'punti', bonus - 1, bonus)
    WHERE   id = 17
    

    or you can also use CASE

    UPDATE  abbonamento
    SET     punti = CASE WHEN tipo = 'punti' THEN punti - 1 ELSE punti END,
            bonus = CASE WHEN tipo <> 'punti' THEN bonus - 1 ELSE bonus END
    WHERE   id = 17
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There seems to have been a backlash from users when Spotify (link below) required
I seems to have some issues in order to compile gproc from uwiger. I
My one activity seems to have grown quite a bit and I feel like
Have a problem that seems easy on paper but i'm having a big problem
This seems to have been asked before: rails decimal precision and scale But when
PowerBuilder seems to have some support for plug-ins since version 10. However, I can't
I have an curious zombie bug that seems to have crept out of the
Hugs seems to have a problem with several non-enbraced !! in a partial application.
It seems I have a problem with JQuery Lite Content Slider. I get a
A question that seems to have quite a few options for Python, but none

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.