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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:14:49+00:00 2026-06-09T06:14:49+00:00

I want to update multiple columns using a single query in MySql with some

  • 0

I want to update multiple columns using a single query in MySql with some condition that is valid across all colums.

I have around 25 databases with the same table structure in them. I need to update a field named Status across all databases for a particular url using a single query using phpMyAdmin.

Right now I am using this query. (I need to set status=2 in table1 in all of these databases where the url is 'www.google.com')

UPDATE  `database1`.`table1` as p1,
    `database2`.`table1` as p2 ,
    `database3`.`table1` as p3
SET  p1.`STATUS` = 2,
    p2.`STATUS`= 2,
    p3.`STATUS`= 2 
WHERE p1.url='www.google.com' and
    p1.url=p2.url=p3.url

But it is updating data in all rows not only url='www.google.com'. It is updating status=2 in 'www.yahoo.com' also.

Please help me to solve this.

  • 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-09T06:14:50+00:00Added an answer on June 9, 2026 at 6:14 am

    This is what you want:

    UPDATE
        database1.table1 AS p1
        LEFT JOIN database2.table1 AS p2 USING (url)
        LEFT JOIN database3.table1 AS p3 USING (url)
    SET
       p1.`STATUS` = 2,
       p2.`STATUS` = 2,
       p3.`STATUS` = 2
    WHERE
        url = 'www.google.com';
    

    and your didn’t work becouse of p1.url=p2.url=p3.url
    thats evaluated as p1.url=(p2.url=p3.url)
    where (p2.url=p3.url) => FALSE for all that didn’t match,
    and then we end up with p1.url=FALSE

    comparing p1.url=FALSE => comparing a string with an boolean,
    converting the string to an integer gives 0 for non numeric string,
    and converting boolean FALSE to integer gives also 0, so p1.url=FALSE

    so p1.url=p2.url=p3.url is the same as NOT p2.url=p3.url

    so your code update all rows where there exists a p2.url thats not equal to all p3.urls

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

Sidebar

Related Questions

I want to update a single datarow in a datatable using multiple threads. Is
I want to update 4 Columns in a particular row in MySQL using C#
I want to select multiple rows from checkbox and want to update them all
I want to run an update query. The query will be run against multiple
I have a table with multiple columns and I want to update only one
I'm updating multiple columns using case when. I want no action taken on cases
i want to update multiple value of my table ORDRE ? table ORDRE CP
What I want to do is update multiple documents with different values in 1
I want to save a set of queries (multiple SQL updates) as a single
What I want: Update all new commits from server with my local repository in

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.