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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:32:49+00:00 2026-05-24T12:32:49+00:00

Is it possible in Mysql to turn this query into 1 query ? UPDATE

  • 0

Is it possible in Mysql to turn this query into 1 query ?

UPDATE users SET users.title =1 WHERE  users.oldId =  'adab01' LIMIT 1 ; 
UPDATE users SET users.title =2 WHERE  users.oldId =  'agok01' LIMIT 1 ; 
UPDATE users SET users.title =1 WHERE  users.oldId =  'alla01' LIMIT 1 ; 
UPDATE users SET users.title =2 WHERE  users.oldId =  'allm01' LIMIT 1 ;

Something similar to this in SELECT :

INSERT INTO users (first_name,last_name) VALUES("John", "Doe"),("Jane", "Doe")

Is this doable in MySql ?

Just so you know what i was trying to do :

I was reading this article , Jump to (Avoid doing SQL queries within a loop)

http://code.google.com/speed/articles/optimizing-php.html

  • 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-24T12:32:50+00:00Added an answer on May 24, 2026 at 12:32 pm

    You’d need to use a CASE statement to do this, and it won’t be terribly pretty:

    UPDATE USER SET USER.title = (CASE USER.oldId
                                  WHEN 'adab01' THEN 1
                                  WHEN 'agok01' THEN 2
                                  WHEN 'alla01' THEN 1
                                  WHEN 'allm01' THEN 2 
                                  ELSE USER.oldID end)
    WHERE USER.oldId in
    (
        'adab01',
        'agok01',
        'alla01',
        'allm01'
    )
    

    Note that the WHERE is optional, as without it the data shouldn’t be changed unnecessarily, but it will also “touch” every row in the table rather than only those that need updating.

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

Sidebar

Related Questions

Is this possible in mysql? update table1 set column1 = (select column1 from table2
I'm not sure if this is possible in one mysql query so I might
Is it possible for me to turn on audit logging on my mysql database?
Is it possible to let MySQL LIMIT have an offset of the total number
Is it possible to import csv data into mysql and automatically create the column
i am looking for a possible MySqL query which will check to see if
Possible Duplicate: Mysql Offset Infinite rows Is it possible to specify a query in
Possible Duplicate: MySQL query using an array How to use an array of values
is it possible in MySQL? In Oracle I could do: SELECT * INTO table
Possible Duplicate: Mysql single query join 3 table and get all the results Hi

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.