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 6203893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:59:43+00:00 2026-05-24T04:59:43+00:00

A while ago @Richard Harris gave a great answer for a similar question ,

  • 0

A while ago @Richard Harris gave a great answer for a similar question, but I believe my situation is slightly different.

As you can see I have 2 consecutive UPDATE statements targeting the same table and fields but with different SET and WHERE clauses.

$this->db->query("
UPDATE user_profiles
SET    reputation = reputation + 15
WHERE  user_id = $answer_author_id;
");

$this->db->query("
UPDATE user_profiles
SET    reputation = reputation + 2
WHERE  user_id = $user_id;
");

I wonder if this can be combined into a single query, or if this requires further normalization. Also, are these consecutive queries too inefficient? If not, I wouldn’t bother trying to combine into a single query.

Your thoughts on this are much appreciated.

  • 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-24T04:59:43+00:00Added an answer on May 24, 2026 at 4:59 am

    you can do this:

    UPDATE user_profiles
    SET    reputation = reputation + 
               case when user_id = $answer_author_id then 15
                    when user_id = $user_id then 2
                    else 0
               end
    WHERE  user_id = $answer_author_id or user_id = $user_id;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A while ago I had a similar question when using Class.getMethod and autoboxing, and
A while ago, I asked a question about $ , and got useful answers
A while ago another question referred to the (possibly urban tale) statistic that ...
A while ago this code seemed to work, but now it doesn't anymore. Is
I've learn a while ago on StackOverflow that we can get the instance ID
A little while ago, I saw a question answered here regarding the fine-grained organization
A while ago I asked this question about how to defer updates to an
A while ago, I saw in regex (at least in PHP) you can make
A while ago I asked this question: using xslt stylesheet to convert xhtml blank
A while ago I asked a question about hierarchy/version number sorting in SQL Server.

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.