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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:11:40+00:00 2026-05-30T12:11:40+00:00

With MYSQL I’m using this query: UPDATE CustomerDetails_COPY SET Category_ID = 10 WHERE Category_ID

  • 0

With MYSQL I’m using this query:

UPDATE CustomerDetails_COPY
SET Category_ID = 10
WHERE Category_ID = 2

Thats fine but I’d like to ad 15+ more SET/WHERE to it like:

UPDATE CustomerDetails_COPY
SET Category_ID = 9  WHERE Category_ID = 3
SET Category_ID = 12 WHERE Category_ID = 4
SET Category_ID = 11 WHERE Category_ID = 5
.....

How would I add to this?

EDIT:

As Per Hunters Suggestion:

UPDATE CustomerDetails_COPY
    SET Category_ID = CASE Category_ID
        WHEN 2 THEN 10 
        WHEN 3 THEN 9
        WHEN 4 THEN 12
        WHEN 5 THEN 11
    END
WHERE Category_ID IN (2,3,4,5)

This works Great! Thanks

  • 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-30T12:11:41+00:00Added an answer on May 30, 2026 at 12:11 pm

    Something like this should work for you:

    UPDATE CustomerDetails_COPY
        SET Category_ID = CASE Category_ID
            WHEN 2 THEN 10 
            WHEN 3 THEN 9
            WHEN 4 THEN 12
            WHEN 5 THEN 11
        END
    WHERE Category_ID IN (2,3,4,5)
    

    Alternatively, as Simon suggested, you could do this to save from entering the values twice:

    UPDATE CustomerDetails_COPY
        SET Category_ID = CASE Category_ID
            WHEN 2 THEN 10 
            WHEN 3 THEN 9
            WHEN 4 THEN 12
            WHEN 5 THEN 11
            ELSE Category_ID
        END
    

    Source: http://www.karlrixon.co.uk/writing/update-multiple-rows-with-different-values-and-a-single-sql-query/

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

Sidebar

Related Questions

mysql_query(UPDATE neuralnetwork set value= value + 1 WHERE varName='count'); This query is increasing value
MySQL is returning a syntax error for this query (via PHP): INSERT INTO links
MySQL, Trying to get a list of ip addresses, in order. this query select
Mysql log has something like: 1649560 Query select * from actions where uniqueid like
MySQL questions are some of my favorites on StackOverflow. Unfortunately, things like this: SELECT
mysql is outputting this error You have an error in your SQL syntax; check
MySQL is giving a 1064 on an escaped string. $date is set above. $article_clean
MySQL like clause lets wildcard searches like '%keyword%' where keyword is sandwiched within the
MySQL query is SELECT option as value, name as text from jos_components where parent
mysql_query(UPDATE rekod SET ns = '1' WHERE zone ='255' AND data ='$id1'); mysql_query(UPDATE rekod

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.