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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:48:09+00:00 2026-06-18T05:48:09+00:00

I need to write a query that finds a single value in multiple columns

  • 0

I need to write a query that finds a single value in multiple columns and then update
those columns where that value exist.

The values that needs to be replaced are in columns that end with _m1

Example table:

o_id   a_m1   a_m2   b_m1   b_m2
1      bb     cc     bb     cc
2      cc     null   bb     cc

I need to find all of the “cc” values in columns that end with _m1 and then update those columns to ‘bb”

  • 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-18T05:48:11+00:00Added an answer on June 18, 2026 at 5:48 am
    UPDATE TABLENAME
      SET a_m1=REPLACE(a_m1,'cc','bb'),
          b_m1=REPLACE(b_m1,'cc','bb')
    

    OR

    SELECT a_m1 = CASE WHEN a_m1='cc' THEN 'bb' ELSE a_m1 END,
           b_m1 = CASE WHEN b_m1='cc' THEN 'bb' ELSE b_m1 END
    

    Note:

    These do two different things — I’m not sure what you want.

    They both only modify a_m1 and b_m1.

    In the first every place in the string where cc occurs is replaced with bb

    In the second if the value equals exactly cc it is changed to bb otherwise no change.

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

Sidebar

Related Questions

I need to write a query that finds all documents created on a specified
In MySQL, I need to write a query (if possible) that finds all rows
I need to write a query that will go through a table, find duplicate
I need to write a query that returns all object less that or equal
Today I came across the need to write a CAML query that uses WHERE
I need to write a SQL query which will get me those rows from
I need to write an NHibernate query that will place a restriction that accesses
Write a SQL query that will display the smallest, largest and range of values
I need to write a query for a table with 5 columns which are
Need help with a query that I wrote: I have three tables Company id

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.