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

  • Home
  • SEARCH
  • 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 6196953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:44:03+00:00 2026-05-24T03:44:03+00:00

This MySQL will increment a user’s reputation by 5 when an upvote is submitted.

  • 0

This MySQL will increment a user’s reputation by 5 when an upvote is submitted.

UPDATE  user_profiles
SET     reputation = reputation +5
WHERE   user_id = $question_author_id;

Now I want to make a distinction:

  • if the upvote is for a question, the increment should be 5,
  • if the upvote is for an answer, the increment should be 10.

An answer can be identified by the presence of an integer in the field forum_qa_parent_id of table forum_qa.

So I came up with this but it doesn’t work:

UPDATE       user_profiles
IF (SELECT   forum_qa_parent_id 
    FROM     forum_qa 
    WHERE    forum_qa_id = $question_id) IS NOT NULL 
    THEN SET reputation = reputation +10 
    WHERE    user_id = $question_author_id;
ELSE SET     reputation = reputation +5 
WHERE        user_id = $question_author_id;
END IF;

Anyone care to show me how to make this work?

  • 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-05-24T03:44:04+00:00Added an answer on May 24, 2026 at 3:44 am

    You need to use a CASE statement if you’re doing logical comparisons within a query. http://dev.mysql.com/doc/refman/5.0/en/case-statement.html

    UPDATE  user_profiles
    SET     reputation = reputation + 
        case when (
            SELECT   forum_qa_parent_id 
            FROM     forum_qa 
            WHERE    forum_qa_id = $question_id) is not null then 10 else 5 end
    WHERE   user_id = $question_author_id;
    

    Something along those lines – you might need to touch that one up a bit.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this MySQL statement from a search page, the user enters there postcode
I would like to add a user defined column which will auto increment on
Will the ID auto-increment value be reset if I drop (wipe) a MySQL table?
This MySQL script installs multiple triggers. It works on one machine running MySQL 5.0.51b-community.
In this MySQL table definition: CREATE TABLE groups ( ug_main_grp_id smallint NOT NULL default
Well I have this MySQL stored procedure that I wrote and if I run
I'm having this Mysql query, It works: SELECT nom ,prenom ,(SELECT GROUP_CONCAT(category_en) FROM (SELECT
I have this mysql table called comments which looks like this: commentID parentID type
I have this mysql tables I want to display with jqgrid. The problem appears
I have this mySQL code that connects to my server. It connects just fine:

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.